Changeset 70058 in vbox for trunk/src/VBox/HostServices/GuestProperties/testcase
- Timestamp:
- Dec 11, 2017 3:02:07 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/testcase/tstGuestPropSvc.cpp
r69500 r70058 106 106 { 107 107 int rc = VINF_SUCCESS; 108 char *pszFlagBuffer = (char *)RTTestGuardedAllocTail(g_hTest, MAX_FLAGS_LEN);108 char *pszFlagBuffer = (char *)RTTestGuardedAllocTail(g_hTest, GUEST_PROP_MAX_FLAGS_LEN); 109 109 110 110 RTTestISub("Conversion of valid flags strings"); … … 112 112 { 113 113 uint32_t fFlags; 114 rc = validateFlags(g_aValidFlagStrings[i].pcszIn, &fFlags);114 rc = GuestPropValidateFlags(g_aValidFlagStrings[i].pcszIn, &fFlags); 115 115 if (RT_FAILURE(rc)) 116 116 RTTestIFailed("Failed to validate flag string '%s'", g_aValidFlagStrings[i].pcszIn); 117 117 if (RT_SUCCESS(rc)) 118 118 { 119 rc = writeFlags(fFlags, pszFlagBuffer);119 rc = GuestPropWriteFlags(fFlags, pszFlagBuffer); 120 120 if (RT_FAILURE(rc)) 121 121 RTTestIFailed("Failed to convert flag string '%s' back to a string.", 122 122 g_aValidFlagStrings[i].pcszIn); 123 123 } 124 if (RT_SUCCESS(rc) && (strlen(pszFlagBuffer) > MAX_FLAGS_LEN - 1))124 if (RT_SUCCESS(rc) && (strlen(pszFlagBuffer) > GUEST_PROP_MAX_FLAGS_LEN - 1)) 125 125 { 126 126 RTTestIFailed("String '%s' converts back to a flag string which is too long.\n", … … 143 143 uint32_t fFlags; 144 144 /* This is required to fail. */ 145 if (RT_SUCCESS( validateFlags(g_apszInvalidFlagStrings[i], &fFlags)))145 if (RT_SUCCESS(GuestPropValidateFlags(g_apszInvalidFlagStrings[i], &fFlags))) 146 146 { 147 147 RTTestIFailed("String '%s' was incorrectly accepted as a valid flag string.\n", … … 153 153 if (RT_SUCCESS(rc)) 154 154 { 155 uint32_t u32BadFlags = ALLFLAGS << 1;155 uint32_t u32BadFlags = GUEST_PROP_F_ALLFLAGS << 1; 156 156 RTTestISub("Rejection of an invalid flags field"); 157 157 /* This is required to fail. */ 158 if (RT_SUCCESS( writeFlags(u32BadFlags, pszFlagBuffer)))158 if (RT_SUCCESS(GuestPropWriteFlags(u32BadFlags, pszFlagBuffer))) 159 159 { 160 160 RTTestIFailed("Flags 0x%x were incorrectly written out as '%.*s'\n", 161 u32BadFlags, MAX_FLAGS_LEN, pszFlagBuffer);161 u32BadFlags, GUEST_PROP_MAX_FLAGS_LEN, pszFlagBuffer); 162 162 rc = VERR_PARSE_ERROR; 163 163 } … … 226 226 aParms[2].setPointer((void *)g_au64TimestampBlock, 0); 227 227 aParms[3].setPointer((void *)g_apcszFlagsBlock, 0); 228 RTTESTI_CHECK_RC(ptable->pfnHostCall(ptable->pvService, SET_PROPS_HOST, 4, &aParms[0]), VINF_SUCCESS);228 RTTESTI_CHECK_RC(ptable->pfnHostCall(ptable->pvService, GUEST_PROP_FN_SET_PROPS_HOST, 4, &aParms[0]), VINF_SUCCESS); 229 229 } 230 230 … … 337 337 aParms[1].setPointer((void *)abBuffer, g_aEnumStrings[i].cbBuffer - 1); 338 338 memset(abBuffer, 0x55, sizeof(abBuffer)); 339 int rc2 = ptable->pfnHostCall(ptable->pvService, ENUM_PROPS_HOST, 3, aParms);339 int rc2 = ptable->pfnHostCall(ptable->pvService, GUEST_PROP_FN_ENUM_PROPS_HOST, 3, aParms); 340 340 if (rc2 == VERR_BUFFER_OVERFLOW) 341 341 { … … 353 353 aParms[1].setPointer((void *)abBuffer, g_aEnumStrings[i].cbBuffer); 354 354 memset(abBuffer, 0x55, sizeof(abBuffer)); 355 rc2 = ptable->pfnHostCall(ptable->pvService, ENUM_PROPS_HOST, 3, aParms);355 rc2 = ptable->pfnHostCall(ptable->pvService, GUEST_PROP_FN_ENUM_PROPS_HOST, 3, aParms); 356 356 if (rc2 == VINF_SUCCESS) 357 357 { … … 394 394 { 395 395 VBOXHGCMCALLHANDLE_TYPEDEF callHandle = { VINF_SUCCESS }; 396 int command = SET_PROP_VALUE;396 int command = GUEST_PROP_FN_SET_PROP_VALUE; 397 397 if (isHost) 398 398 { 399 399 if (useSetProp) 400 command = SET_PROP_HOST;400 command = GUEST_PROP_FN_SET_PROP_HOST; 401 401 else 402 command = SET_PROP_VALUE_HOST;402 command = GUEST_PROP_FN_SET_PROP_VALUE_HOST; 403 403 } 404 404 else if (useSetProp) 405 command = SET_PROP;405 command = GUEST_PROP_FN_SET_PROP; 406 406 VBOXHGCMSVCPARM aParms[3]; 407 407 /* Work around silly constant issues - we ought to allow passing 408 408 * constant strings in the hgcm parameters. */ 409 char szName[ MAX_NAME_LEN];410 char szValue[ MAX_VALUE_LEN];411 char szFlags[ MAX_FLAGS_LEN];409 char szName[GUEST_PROP_MAX_NAME_LEN]; 410 char szValue[GUEST_PROP_MAX_VALUE_LEN]; 411 char szFlags[GUEST_PROP_MAX_FLAGS_LEN]; 412 412 RTStrPrintf(szName, sizeof(szName), "%s", pcszName); 413 413 RTStrPrintf(szValue, sizeof(szValue), "%s", pcszValue); … … 493 493 { 494 494 VBOXHGCMCALLHANDLE_TYPEDEF callHandle = { VINF_SUCCESS }; 495 int command = DEL_PROP;495 int command = GUEST_PROP_FN_DEL_PROP; 496 496 if (isHost) 497 command = DEL_PROP_HOST;497 command = GUEST_PROP_FN_DEL_PROP_HOST; 498 498 VBOXHGCMSVCPARM aParms[1]; 499 499 aParms[0].setString(pcszName); … … 595 595 /* Work around silly constant issues - we ought to allow passing 596 596 * constant strings in the hgcm parameters. */ 597 char szBuffer[ MAX_VALUE_LEN +MAX_FLAGS_LEN];597 char szBuffer[GUEST_PROP_MAX_VALUE_LEN + GUEST_PROP_MAX_FLAGS_LEN]; 598 598 RTTESTI_CHECK_RETV(s_aGetProperties[i].cchValue < sizeof(szBuffer)); 599 599 … … 601 601 memset(szBuffer, 0x55, sizeof(szBuffer)); 602 602 aParms[1].setPointer(szBuffer, sizeof(szBuffer)); 603 int rc2 = pTable->pfnHostCall(pTable->pvService, G ET_PROP_HOST, 4, aParms);603 int rc2 = pTable->pfnHostCall(pTable->pvService, GUEST_PROP_FN_GET_PROP_HOST, 4, aParms); 604 604 605 605 if (s_aGetProperties[i].exists && RT_FAILURE(rc2)) … … 689 689 aParms[1].setUInt64(1); 690 690 aParms[2].setPointer(pvBuf, cbBuf); 691 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, G ET_NOTIFICATION, 4, aParms);691 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GUEST_PROP_FN_GET_NOTIFICATION, 4, aParms); 692 692 693 693 if ( callHandle.rc != VERR_BUFFER_OVERFLOW … … 715 715 aParms[1].setUInt64(u64Timestamp); 716 716 aParms[2].setPointer(pvBuf, cbBuf); 717 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, G ET_NOTIFICATION, 4, aParms);717 pTable->pfnCall(pTable->pvService, &callHandle, 0, NULL, GUEST_PROP_FN_GET_NOTIFICATION, 4, aParms); 718 718 if ( RT_FAILURE(callHandle.rc) 719 719 || (i == 0 && callHandle.rc != VWRN_NOT_FOUND) … … 737 737 VBOXHGCMSVCPARM aParms[4]; 738 738 /** Result buffer */ 739 char abBuffer[ MAX_NAME_LEN + MAX_VALUE_LEN +MAX_FLAGS_LEN];739 char abBuffer[GUEST_PROP_MAX_NAME_LEN + GUEST_PROP_MAX_VALUE_LEN + GUEST_PROP_MAX_FLAGS_LEN]; 740 740 /** Return value */ 741 741 VBOXHGCMCALLHANDLE_TYPEDEF callHandle; … … 756 756 g_AsyncNotification.callHandle.rc = VINF_HGCM_ASYNC_EXECUTE; 757 757 pTable->pfnCall(pTable->pvService, &g_AsyncNotification.callHandle, 0, NULL, 758 G ET_NOTIFICATION, 4, g_AsyncNotification.aParms);758 GUEST_PROP_FN_GET_NOTIFICATION, 4, g_AsyncNotification.aParms); 759 759 if (RT_FAILURE(g_AsyncNotification.callHandle.rc)) 760 760 RTTestIFailed("GET_NOTIFICATION call failed, rc=%Rrc.", g_AsyncNotification.callHandle.rc); … … 815 815 * 816 816 * @param pTable the service instance handle 817 * @param eFlags the flags to set818 */ 819 static int doSetGlobalFlags(VBOXHGCMSVCFNTABLE *pTable, ePropFlags eFlags)817 * @param fFlags the flags to set 818 */ 819 static int doSetGlobalFlags(VBOXHGCMSVCFNTABLE *pTable, uint32_t fFlags) 820 820 { 821 821 VBOXHGCMSVCPARM paParm; 822 paParm.setUInt32( eFlags);823 int rc = pTable->pfnHostCall(pTable->pvService, SET_GLOBAL_FLAGS_HOST, 1, &paParm);822 paParm.setUInt32(fFlags); 823 int rc = pTable->pfnHostCall(pTable->pvService, GUEST_PROP_FN_SET_GLOBAL_FLAGS_HOST, 1, &paParm); 824 824 if (RT_FAILURE(rc)) 825 825 { 826 char szFlags[ MAX_FLAGS_LEN];827 if (RT_FAILURE( writeFlags(eFlags, szFlags)))826 char szFlags[GUEST_PROP_MAX_FLAGS_LEN]; 827 if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags))) 828 828 RTTestIFailed("Failed to set the global flags."); 829 829 else … … 874 874 875 875 RTTESTI_CHECK_RC_OK_RETV(VBoxHGCMSvcLoad(pTable)); 876 int rc = doSetGlobalFlags(pTable, RDONLYGUEST);876 int rc = doSetGlobalFlags(pTable, GUEST_PROP_F_RDONLYGUEST); 877 877 if (RT_SUCCESS(rc)) 878 878 { … … 942 942 943 943 RTTESTI_CHECK_RC_OK_RETV(VBoxHGCMSvcLoad(pTable)); 944 int rc = doSetGlobalFlags(pTable, RDONLYGUEST);944 int rc = doSetGlobalFlags(pTable, GUEST_PROP_F_RDONLYGUEST); 945 945 if (RT_SUCCESS(rc)) 946 946 { … … 1006 1006 aParms[0].setString(s_szProp); 1007 1007 aParms[1].setPointer(pvBuf, cbBuf); 1008 svcTable.pfnHostCall(svcTable.pvService, G ET_PROP_HOST, RT_ELEMENTS(aParms), aParms);1008 svcTable.pfnHostCall(svcTable.pvService, GUEST_PROP_FN_GET_PROP_HOST, RT_ELEMENTS(aParms), aParms); 1009 1009 1010 1010 RTTestGuardedFree(g_hTest, pvBuf); … … 1042 1042 aParms[0].setString("*"); 1043 1043 aParms[1].setPointer(pvBuf, cbBuf); 1044 svcTable.pfnHostCall(svcTable.pvService, ENUM_PROPS_HOST, RT_ELEMENTS(aParms), aParms);1044 svcTable.pfnHostCall(svcTable.pvService, GUEST_PROP_FN_ENUM_PROPS_HOST, RT_ELEMENTS(aParms), aParms); 1045 1045 1046 1046 RTTestGuardedFree(g_hTest, pvBuf); … … 1111 1111 aParms[0].setPointer(szProp, (uint32_t)cchProp + 1); 1112 1112 aParms[1].setPointer(szBuffer, sizeof(szBuffer)); 1113 RTTESTI_CHECK_RC_BREAK(svcTable.pfnHostCall(svcTable.pvService, G ET_PROP_HOST, 4, aParms), VINF_SUCCESS);1113 RTTESTI_CHECK_RC_BREAK(svcTable.pfnHostCall(svcTable.pvService, GUEST_PROP_FN_GET_PROP_HOST, 4, aParms), VINF_SUCCESS); 1114 1114 } 1115 1115 cNsElapsed = RTTimeNanoTS() - cNsElapsed;
Note:
See TracChangeset
for help on using the changeset viewer.