void testFlushFileSimple(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; const RTFILE hcFile = (RTFILE) 0x10000; SHFLHANDLE Handle; int rc; RTTestSub(hTest, "Flush file simple"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTFileOpenpFile = hcFile; rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, &Handle, NULL); RTTEST_CHECK_RC_OK(hTest, rc); rc = flushFile(&svcTable, Root, Handle); RTTEST_CHECK_RC_OK(hTest, rc); RTTEST_CHECK_MSG(hTest, testRTFileFlushFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileFlushFile))); unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); RTTEST_CHECK_MSG(hTest, testRTFileCloseFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileCloseFile))); }
void testDirListEmpty(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; PRTDIR pcDir = (PRTDIR)0x10000; SHFLHANDLE Handle; SHFLDIRINFO DirInfo; uint32_t cFiles; int rc; RTTestSub(hTest, "List empty directory"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTDirOpenpDir = pcDir; rc = createFile(&svcTable, Root, "test/dir", SHFL_CF_DIRECTORY | SHFL_CF_ACCESS_READ, &Handle, NULL); RTTEST_CHECK_RC_OK(hTest, rc); rc = listDir(&svcTable, Root, Handle, 0, sizeof (SHFLDIRINFO), NULL, &DirInfo, sizeof(DirInfo), 0, &cFiles); RTTEST_CHECK_RC(hTest, rc, VERR_NO_MORE_FILES); RTTEST_CHECK_MSG(hTest, testRTDirReadExDir == pcDir, (hTest, "Dir=%llu\n", LLUIFY(testRTDirReadExDir))); RTTEST_CHECK_MSG(hTest, cFiles == 0, (hTest, "cFiles=%llu\n", LLUIFY(cFiles))); unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); RTTEST_CHECK_MSG(hTest, testRTDirClosepDir == pcDir, (hTest, "pDir=%llu\n", LLUIFY(testRTDirClosepDir))); }
void testReadFileSimple(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; const RTFILE hcFile = (RTFILE) 0x10000; SHFLHANDLE Handle; const char *pcszReadData = "Data to read"; char acBuf[sizeof(pcszReadData) + 10]; uint32_t cbRead; int rc; RTTestSub(hTest, "Read file simple"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTFileOpenpFile = hcFile; rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, &Handle, NULL); RTTEST_CHECK_RC_OK(hTest, rc); testRTFileReadData = pcszReadData; rc = readFile(&svcTable, Root, Handle, 0, strlen(pcszReadData) + 1, &cbRead, acBuf, (uint32_t)sizeof(acBuf)); RTTEST_CHECK_RC_OK(hTest, rc); RTTEST_CHECK_MSG(hTest, !strncmp(acBuf, pcszReadData, sizeof(acBuf)), (hTest, "pvBuf=%.*s\n", sizeof(acBuf), acBuf)); RTTEST_CHECK_MSG(hTest, cbRead == strlen(pcszReadData) + 1, (hTest, "cbRead=%llu\n", LLUIFY(cbRead))); unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); RTTEST_CHECK_MSG(hTest, testRTFileCloseFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileCloseFile))); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); }
void testWriteFileSimple(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; const RTFILE hcFile = (RTFILE) 0x10000; SHFLHANDLE Handle; const char *pcszWrittenData = "Data to write"; uint32_t cbToWrite = (uint32_t)strlen(pcszWrittenData) + 1; uint32_t cbWritten; int rc; RTTestSub(hTest, "Write file simple"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTFileOpenpFile = hcFile; rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, &Handle, NULL); RTTEST_CHECK_RC_OK(hTest, rc); rc = writeFile(&svcTable, Root, Handle, 0, cbToWrite, &cbWritten, pcszWrittenData, cbToWrite); RTTEST_CHECK_RC_OK(hTest, rc); RTTEST_CHECK_MSG(hTest, !strcmp(testRTFileWriteData, pcszWrittenData), (hTest, "pvBuf=%s\n", testRTFileWriteData)); RTTEST_CHECK_MSG(hTest, cbWritten == cbToWrite, (hTest, "cbWritten=%llu\n", LLUIFY(cbWritten))); unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); RTTEST_CHECK_MSG(hTest, testRTFileCloseFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileCloseFile))); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); }
void testCreateFileSimple(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; const RTFILE hcFile = (RTFILE) 0x10000; SHFLCREATERESULT Result; int rc; RTTestSub(hTest, "Create file simple"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTFileOpenpFile = hcFile; rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, NULL, &Result); RTTEST_CHECK_RC_OK(hTest, rc); RTTEST_CHECK_MSG(hTest, !strcmp(testRTFileOpenName, "/test/mapping/test/file"), (hTest, "pszFilename=%s\n", testRTFileOpenName)); RTTEST_CHECK_MSG(hTest, testRTFileOpenFlags == 0x181, (hTest, "fOpen=%llu\n", LLUIFY(testRTFileOpenFlags))); RTTEST_CHECK_MSG(hTest, Result == SHFL_FILE_CREATED, (hTest, "Result=%d\n", (int) Result)); unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); RTTEST_CHECK_MSG(hTest, testRTFileCloseFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileCloseFile))); }
void testCreateDirSimple(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; PRTDIR pcDir = (PRTDIR)0x10000; SHFLCREATERESULT Result; int rc; RTTestSub(hTest, "Create directory simple"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTDirOpenpDir = pcDir; rc = createFile(&svcTable, Root, "test/dir", SHFL_CF_DIRECTORY | SHFL_CF_ACCESS_READ, NULL, &Result); RTTEST_CHECK_RC_OK(hTest, rc); RTTEST_CHECK_MSG(hTest, !strcmp(testRTDirCreatePath, "/test/mapping/test/dir"), (hTest, "pszPath=%s\n", testRTDirCreatePath)); RTTEST_CHECK_MSG(hTest, !strcmp(testRTDirOpenName, "/test/mapping/test/dir"), (hTest, "pszFilename=%s\n", testRTDirOpenName)); RTTEST_CHECK_MSG(hTest, Result == SHFL_FILE_CREATED, (hTest, "Result=%d\n", (int) Result)); unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); RTTEST_CHECK_MSG(hTest, testRTDirClosepDir == pcDir, (hTest, "pDir=%llu\n", LLUIFY(testRTDirClosepDir))); }
void testFSInfoQuerySetEndOfFile(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; const RTFILE hcFile = (RTFILE) 0x10000; const RTFOFF cbNew = 50000; SHFLFSOBJINFO Info; SHFLHANDLE Handle; int rc; RTTestSub(hTest, "Set end of file position"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTFileOpenpFile = hcFile; rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, &Handle, NULL); RTTEST_CHECK_RC_OK(hTest, rc); RT_ZERO(Info); Info.cbObject = cbNew; rc = sfInformation(&svcTable, Root, Handle, SHFL_INFO_SET | SHFL_INFO_SIZE, sizeof(Info), &Info); RTTEST_CHECK_RC_OK(hTest, rc); RTTEST_CHECK_MSG(hTest, testRTFileSetSizeFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileSetSizeFile))); RTTEST_CHECK_MSG(hTest, testRTFileSetSizeSize == cbNew, (hTest, "Size=%llu\n", LLUIFY(testRTFileSetSizeSize))); unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); RTTEST_CHECK_MSG(hTest, testRTFileCloseFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileCloseFile))); }
static void test4(void) { RTTestISub("GET_PROP_HOST buffer handling"); VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; initTable(&svcTable, &svcHelpers); RTTESTI_CHECK_RC_OK_RETV(VBoxHGCMSvcLoad(&svcTable)); /* Insert a property that we can mess around with. */ static char const s_szProp[] = "/MyProperties/Sub/Sub/Sub/Sub/Sub/Sub/Sub/Property"; static char const s_szValue[] = "Property Value"; RTTESTI_CHECK_RC_OK(doSetProperty(&svcTable, s_szProp, s_szValue, "", true, true)); /* Get the value with buffer sizes up to 1K. */ for (unsigned iVariation = 0; iVariation < 2; iVariation++) { for (uint32_t cbBuf = 0; cbBuf < _1K; cbBuf++) { void *pvBuf; RTTESTI_CHECK_RC_BREAK(RTTestGuardedAlloc(g_hTest, cbBuf, 1, iVariation == 0, &pvBuf), VINF_SUCCESS); VBOXHGCMSVCPARM aParms[4]; aParms[0].setString(s_szProp); aParms[1].setPointer(pvBuf, cbBuf); int rc = svcTable.pfnHostCall(svcTable.pvService, GET_PROP_HOST, RT_ELEMENTS(aParms), aParms); RTTestGuardedFree(g_hTest, pvBuf); } } /* Done. */ RTTESTI_CHECK_RC_OK(svcTable.pfnUnload(svcTable.pvService)); }
static void test2(void) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; initTable(&svcTable, &svcHelpers); /* The function is inside the service, not HGCM. */ RTTESTI_CHECK_RC_OK_RETV(VBoxHGCMSvcLoad(&svcTable)); testSetPropsHost(&svcTable); testEnumPropsHost(&svcTable); /* Set up the asynchronous notification test */ setupAsyncNotification(&svcTable); testSetProp(&svcTable); RTTestISub("Async notification call data"); testAsyncNotification(&svcTable); /* Our previous notification call should have completed by now. */ testDelProp(&svcTable); testGetProp(&svcTable); testGetNotification(&svcTable); /* Cleanup */ RTTESTI_CHECK_RC_OK(svcTable.pfnUnload(svcTable.pvService)); }
static void test5(void) { RTTestISub("ENUM_PROPS_HOST buffer handling"); VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; initTable(&svcTable, &svcHelpers); RTTESTI_CHECK_RC_OK_RETV(VBoxHGCMSvcLoad(&svcTable)); /* Insert a few property that we can mess around with. */ RTTESTI_CHECK_RC_OK(doSetProperty(&svcTable, "/MyProperties/Sub/Sub/Sub/Sub/Sub/Sub/Sub/Property", "Property Value", "", true, true)); RTTESTI_CHECK_RC_OK(doSetProperty(&svcTable, "/MyProperties/12357", "83848569", "", true, true)); RTTESTI_CHECK_RC_OK(doSetProperty(&svcTable, "/MyProperties/56678", "abcdefghijklm", "", true, true)); RTTESTI_CHECK_RC_OK(doSetProperty(&svcTable, "/MyProperties/932769", "n", "", true, true)); /* Get the value with buffer sizes up to 1K. */ for (unsigned iVariation = 0; iVariation < 2; iVariation++) { for (uint32_t cbBuf = 0; cbBuf < _1K; cbBuf++) { void *pvBuf; RTTESTI_CHECK_RC_BREAK(RTTestGuardedAlloc(g_hTest, cbBuf, 1, iVariation == 0, &pvBuf), VINF_SUCCESS); VBOXHGCMSVCPARM aParms[3]; aParms[0].setString("*"); aParms[1].setPointer(pvBuf, cbBuf); int rc2 = svcTable.pfnHostCall(svcTable.pvService, ENUM_PROPS_HOST, RT_ELEMENTS(aParms), aParms); RTTestGuardedFree(g_hTest, pvBuf); } } /* Done. */ RTTESTI_CHECK_RC_OK(svcTable.pfnUnload(svcTable.pvService)); }
int main(int argc, char **argv) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; RTEXITCODE rcExit; rcExit = RTTestInitAndCreate("tstGuestPropSvc", &g_hTest); if (rcExit != RTEXITCODE_SUCCESS) return rcExit; RTTestBanner(g_hTest); /** @todo convert the rest of this testcase. */ initTable(&svcTable, &svcHelpers); if (RT_FAILURE(testConvertFlags())) return 1; /* The function is inside the service, not HGCM. */ if (RT_FAILURE(VBoxHGCMSvcLoad(&svcTable))) { RTPrintf("Failed to start the HGCM service.\n"); return 1; } if (RT_FAILURE(testSetPropsHost(&svcTable))) return 1; if (RT_FAILURE(testEnumPropsHost(&svcTable))) return 1; /* Set up the asynchronous notification test */ if (RT_FAILURE(setupAsyncNotification(&svcTable))) return 1; if (RT_FAILURE(testSetProp(&svcTable))) return 1; RTPrintf("Checking the data returned by the asynchronous notification call.\n"); /* Our previous notification call should have completed by now. */ if (RT_FAILURE(testAsyncNotification(&svcTable))) return 1; if (RT_FAILURE(testDelProp(&svcTable))) return 1; if (RT_FAILURE(testGetProp(&svcTable))) return 1; if (RT_FAILURE(testGetNotification(&svcTable))) return 1; if (RT_FAILURE(svcTable.pfnUnload(svcTable.pvService))) { RTPrintf("Failed to unload the HGCM service.\n"); return 1; } if (RT_FAILURE(testSetPropROGuest(&svcTable))) return 1; if (RT_FAILURE(testDelPropROGuest(&svcTable))) return 1; return RTTestSummaryAndDestroy(g_hTest); }
void testLockFileSimple(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; const RTFILE hcFile = (RTFILE) 0x10000; const int64_t offLock = 50000; const uint64_t cbLock = 4000; SHFLHANDLE Handle; int rc; RTTestSub(hTest, "Simple file lock and unlock"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTFileOpenpFile = hcFile; rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, &Handle, NULL); RTTEST_CHECK_RC_OK(hTest, rc); rc = lockFile(&svcTable, Root, Handle, offLock, cbLock, SHFL_LOCK_SHARED); RTTEST_CHECK_RC_OK(hTest, rc); #ifdef RT_OS_WINDOWS /* Locking is a no-op elsewhere. */ RTTEST_CHECK_MSG(hTest, testRTFileLockFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileLockFile))); RTTEST_CHECK_MSG(hTest, testRTFileLockfLock == 0, (hTest, "fLock=%u\n", testRTFileLockfLock)); RTTEST_CHECK_MSG(hTest, testRTFileLockOffset == offLock, (hTest, "Offs=%llu\n", (long long) testRTFileLockOffset)); RTTEST_CHECK_MSG(hTest, testRTFileLockSize == cbLock, (hTest, "Size=%llu\n", LLUIFY(testRTFileLockSize))); #endif rc = lockFile(&svcTable, Root, Handle, offLock, cbLock, SHFL_LOCK_CANCEL); RTTEST_CHECK_RC_OK(hTest, rc); #ifdef RT_OS_WINDOWS RTTEST_CHECK_MSG(hTest, testRTFileUnlockFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileUnlockFile))); RTTEST_CHECK_MSG(hTest, testRTFileUnlockOffset == offLock, (hTest, "Offs=%llu\n", (long long) testRTFileUnlockOffset)); RTTEST_CHECK_MSG(hTest, testRTFileUnlockSize == cbLock, (hTest, "Size=%llu\n", LLUIFY(testRTFileUnlockSize))); #endif unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); RTTEST_CHECK_MSG(hTest, testRTFileCloseFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileCloseFile))); }
void testFSInfoQuerySetFileATime(RTTEST hTest) { VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; SHFLROOT Root; const RTFILE hcFile = (RTFILE) 0x10000; const int64_t ccAtimeNano = 100000; SHFLFSOBJINFO Info; SHFLHANDLE Handle; int rc; RTTestSub(hTest, "Query and set file atime"); Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers, "/test/mapping", "testname"); testRTFileOpenpFile = hcFile; rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ, &Handle, NULL); RTTEST_CHECK_RC_OK(hTest, rc); RT_ZERO(Info); RTTimeSpecSetNano(&testRTFileQueryInfoATime, ccAtimeNano); rc = sfInformation(&svcTable, Root, Handle, SHFL_INFO_FILE, sizeof(Info), &Info); RTTEST_CHECK_RC_OK(hTest, rc); RTTEST_CHECK_MSG(hTest, testRTFileQueryInfoFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileQueryInfoFile))); RTTEST_CHECK_MSG(hTest, RTTimeSpecGetNano(&Info.AccessTime) == ccAtimeNano, (hTest, "ATime=%llu\n", LLUIFY(RTTimeSpecGetNano(&Info.AccessTime)))); RT_ZERO(Info); RTTimeSpecSetNano(&Info.AccessTime, ccAtimeNano); rc = sfInformation(&svcTable, Root, Handle, SHFL_INFO_SET | SHFL_INFO_FILE, sizeof(Info), &Info); RTTEST_CHECK_RC_OK(hTest, rc); RTTEST_CHECK_MSG(hTest, RTTimeSpecGetNano(&testRTFileSetTimesATime) == ccAtimeNano, (hTest, "ATime=%llu\n", LLUIFY(RTTimeSpecGetNano(&testRTFileSetTimesATime)))); unmapAndRemoveMapping(hTest, &svcTable, Root, "testname"); AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService)); RTTestGuardedFree(hTest, svcTable.pvService); RTTEST_CHECK_MSG(hTest, testRTFileCloseFile == hcFile, (hTest, "File=%llu\n", LLUIFY(testRTFileCloseFile))); }
static void test6(void) { RTTestISub("Max properties"); VBOXHGCMSVCFNTABLE svcTable; VBOXHGCMSVCHELPERS svcHelpers; initTable(&svcTable, &svcHelpers); RTTESTI_CHECK_RC_OK_RETV(VBoxHGCMSvcLoad(&svcTable)); /* Insert the max number of properties. */ static char const s_szPropFmt[] = "/MyProperties/Sub/Sub/Sub/Sub/Sub/Sub/Sub/PropertyNo#%u"; char szProp[80]; unsigned cProps = 0; for (;;) { RTStrPrintf(szProp, sizeof(szProp), s_szPropFmt, cProps); int rc = doSetProperty(&svcTable, szProp, "myvalue", "", true, true); if (rc == VERR_TOO_MUCH_DATA) break; if (RT_FAILURE(rc)) { RTTestIFailed("Unexpected error %Rrc setting property number %u", rc, cProps); break; } cProps++; } RTTestIValue("Max Properties", cProps, RTTESTUNIT_OCCURRENCES); /* Touch them all again. */ for (unsigned iProp = 0; iProp < cProps; iProp++) { RTStrPrintf(szProp, sizeof(szProp), s_szPropFmt, iProp); int rc; RTTESTI_CHECK_MSG((rc = doSetProperty(&svcTable, szProp, "myvalue", "", true, true)) == VINF_SUCCESS, ("%Rrc - #%u\n", rc, iProp)); RTTESTI_CHECK_MSG((rc = doSetProperty(&svcTable, szProp, "myvalue", "", true, false)) == VINF_SUCCESS, ("%Rrc - #%u\n", rc, iProp)); RTTESTI_CHECK_MSG((rc = doSetProperty(&svcTable, szProp, "myvalue", "", false, true)) == VINF_SUCCESS, ("%Rrc - #%u\n", rc, iProp)); RTTESTI_CHECK_MSG((rc = doSetProperty(&svcTable, szProp, "myvalue", "", false, false)) == VINF_SUCCESS, ("%Rrc - #%u\n", rc, iProp)); } /* Benchmark. */ uint64_t cNsMax = 0; uint64_t cNsMin = UINT64_MAX; uint64_t cNsAvg = 0; for (unsigned iProp = 0; iProp < cProps; iProp++) { size_t cchProp = RTStrPrintf(szProp, sizeof(szProp), s_szPropFmt, iProp); uint64_t cNsElapsed = RTTimeNanoTS(); unsigned iCall; for (iCall = 0; iCall < 1000; iCall++) { VBOXHGCMSVCPARM aParms[4]; char szBuffer[256]; aParms[0].setPointer(szProp, cchProp + 1); aParms[1].setPointer(szBuffer, sizeof(szBuffer)); RTTESTI_CHECK_RC_BREAK(svcTable.pfnHostCall(svcTable.pvService, GET_PROP_HOST, 4, aParms), VINF_SUCCESS); } cNsElapsed = RTTimeNanoTS() - cNsElapsed; if (iCall) { uint64_t cNsPerCall = cNsElapsed / iCall; cNsAvg += cNsPerCall; if (cNsPerCall < cNsMin) cNsMin = cNsPerCall; if (cNsPerCall > cNsMax) cNsMax = cNsPerCall; } } if (cProps) cNsAvg /= cProps; RTTestIValue("GET_PROP_HOST Min", cNsMin, RTTESTUNIT_NS_PER_CALL); RTTestIValue("GET_PROP_HOST Avg", cNsAvg, RTTESTUNIT_NS_PER_CALL); RTTestIValue("GET_PROP_HOST Max", cNsMax, RTTESTUNIT_NS_PER_CALL); /* Done. */ RTTESTI_CHECK_RC_OK(svcTable.pfnUnload(svcTable.pvService)); }