本文整理汇总了C++中RTTestInitAndCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ RTTestInitAndCreate函数的具体用法?C++ RTTestInitAndCreate怎么用?C++ RTTestInitAndCreate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTTestInitAndCreate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
RTEXITCODE rcExit = RTTestInitAndCreate("tstNtQueryStuff", &g_hTest);
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
RTTestBanner(g_hTest);
g_hProcess = GetCurrentProcess();
if (argc >= 2 && argv[1][0] != '-')
{
const char *pszPid = argv[1];
uint32_t idPid = RTStrToInt32(pszPid);
uint32_t fAccess = PROCESS_QUERY_INFORMATION;
if (argc >= 3)
fAccess = RTStrToInt32(argv[2]);
g_hProcess = OpenProcess(fAccess, FALSE, idPid);
if (g_hProcess == NULL)
{
RTTestIFailed("Error %u opening process %u (%s)\n", GetLastError(), idPid, pszPid);
return RTTestSummaryAndDestroy(g_hTest);
}
}
tstQueryVirtualMemory();
tstQueryInformationProcess();
return RTTestSummaryAndDestroy(g_hTest);
}
示例2: main
int main()
{
RTTEST hTest;
RTEXITCODE rcExit = RTTestInitAndCreate("tstRTDirCreateUniqueNumbered", &hTest);
if (rcExit)
return rcExit;
RTTestBanner(hTest);
/*
* Get the temp directory (this is essential to the testcase).
*/
int rc;
RTTESTI_CHECK_RC(rc = RTPathTemp(g_szTempPath, sizeof(g_szTempPath)), VINF_SUCCESS);
if (RT_FAILURE(rc))
return RTTestSummaryAndDestroy(hTest);
/*
* Create some test directories.
*/
tst1(1, 1, 0 );
tst1(2, 1, '-');
tst1(3, 2, 0 );
tst1(4, 2, '-');
/*
* Summary.
*/
return RTTestSummaryAndDestroy(hTest);
}
示例3: main
int main(int argc, char **argv)
{
RTTEST hTest;
RTEXITCODE rcExit = RTTestInitAndCreate("tstDisasm", &hTest);
if (rcExit)
return rcExit;
RTTestBanner(hTest);
static const struct
{
const char *pszDesc;
uint8_t const *pbStart;
uintptr_t uEndPtr;
DISCPUMODE enmCpuMode;
} aSnippets[] =
{
{ "32-bit", (uint8_t const *)(uintptr_t)TestProc32, (uintptr_t)&TestProc32_EndProc, DISCPUMODE_32BIT },
{ "64-bit", (uint8_t const *)(uintptr_t)TestProc64, (uintptr_t)&TestProc64_EndProc, DISCPUMODE_64BIT },
};
for (unsigned i = 0; i < RT_ELEMENTS(aSnippets); i++)
testDisas(aSnippets[i].pszDesc, aSnippets[i].pbStart, aSnippets[i].uEndPtr, aSnippets[i].enmCpuMode);
if (RTTestIErrorCount() == 0)
{
for (unsigned i = 0; i < RT_ELEMENTS(aSnippets); i++)
testPerformance(aSnippets[i].pszDesc, aSnippets[i].pbStart, aSnippets[i].uEndPtr, aSnippets[i].enmCpuMode);
}
return RTTestSummaryAndDestroy(hTest);
}
示例4: main
int main()
{
RTTEST hTest;
int rc = RTTestInitAndCreate("tstRTTemp", &hTest);
if (rc)
return rc;
RTTestBanner(hTest);
/*
* Get the temp directory (this is essential to the testcase).
*/
RTTESTI_CHECK_RC(rc = RTPathTemp(g_szTempPath, sizeof(g_szTempPath)), VINF_SUCCESS);
if (RT_FAILURE(rc))
return RTTestSummaryAndDestroy(hTest);
/*
* Create N temporary files and directories using RT(File|Dir)CreateTemp.
*/
tstBothCreateTemp("#1 (standard)", "rtRTTemp-XXXXXX", 0700, 128, false /*fSkipXCheck*/);
tstBothCreateTemp("#2 (long)", "rtRTTemp-XXXXXXXXXXXXXXXXX", 0700, 128, false /*fSkipXCheck*/);
tstBothCreateTemp("#3 (short)", "rtRTTemp-XX", 0777, 128, false /*fSkipXCheck*/);
tstBothCreateTemp("#4 (very short)", "rtRTTemp-X", 0100, 26+10, false /*fSkipXCheck*/);
tstBothCreateTemp("#5 (in-name)", "rtRTTemp-XXXt", 0301, 2, false /*fSkipXCheck*/);
tstBothCreateTemp("#6 (in-name)", "XXX-rtRTTemp", 0355, 2, false /*fSkipXCheck*/);
tstBothCreateTemp("#7 (in-name)", "rtRTTemp-XXXXXXXXX.tmp", 0755, 128, false /*fSkipXCheck*/);
tstBothCreateTemp("#8 (in-name)", "rtRTTemp-XXXXXXX-X.tmp", 0700, 128, true /*fSkipXCheck*/);
tstBothCreateTemp("#9 (in-name)", "rtRTTemp-XXXXXX-XX.tmp", 0700, 128, true /*fSkipXCheck*/);
/*
* Summary.
*/
return RTTestSummaryAndDestroy(hTest);
}
示例5: main
int main(int argc, char **argv)
{
RTR3InitExe(argc, &argv, 0);
/*
* Initialize IPRT and create the test.
*/
RTTEST hTest;
int rc = RTTestInitAndCreate("tstAudioMixBuffer", &hTest);
if (rc)
return rc;
RTTestBanner(hTest);
rc = tstSingle(hTest);
if (RT_SUCCESS(rc))
rc = tstParentChild(hTest);
if (RT_SUCCESS(rc))
rc = tstConversion8(hTest);
if (RT_SUCCESS(rc))
rc = tstConversion16(hTest);
if (RT_SUCCESS(rc))
rc = tstVolume(hTest);
/*
* Summary
*/
return RTTestSummaryAndDestroy(hTest);
}
示例6: main
int main()
{
RTTEST hTest;
int rc = RTTestInitAndCreate("tstRTPoll", &hTest);
if (rc)
return rc;
RTTestBanner(hTest);
/*
* The tests.
*/
tstRTPoll1();
if (RTTestErrorCount(hTest) == 0)
{
bool fMayPanic = RTAssertMayPanic();
bool fQuiet = RTAssertAreQuiet();
RTAssertSetMayPanic(false);
RTAssertSetQuiet(true);
tstRTPoll2();
RTAssertSetQuiet(fQuiet);
RTAssertSetMayPanic(fMayPanic);
}
/*
* Summary.
*/
return RTTestSummaryAndDestroy(hTest);
}
示例7: main
int main(int argc, char **argv)
{
RTTEST hTest;
int rc = RTTestInitAndCreate("tstRTFileGetSize-1", &hTest);
if (rc)
return rc;
RTTestBanner(hTest);
for (int i = 0; i < argc; i++)
{
char *pszNm = RTPathFilename(argv[i]);
if (!pszNm)
pszNm = argv[i];
test1(pszNm, argv[i]);
}
#ifdef RT_OS_WINDOWS
test1("//./PhysicalDrive0", "//./PhysicalDrive0");
test1("//./HarddiskVolume1", "//./HarddiskVolume1");
test1("//./null", "//./nul");
#else
test1("/dev/null", "/dev/null");
# ifdef RT_OS_LINUX
test1("/dev/sda", "/dev/sda");
test1("/dev/sda1", "/dev/sda1");
test1("/dev/sda5", "/dev/sda5");
# endif
#endif
/*
* Summary.
*/
return RTTestSummaryAndDestroy(hTest);
}
示例8: main
int main()
{
int rc = RTTestInitAndCreate("tstRTFileAio", &g_hTest);
if (rc)
return rc;
/* Check if the API is available. */
RTTestSub(g_hTest, "RTFileAioGetLimits");
RTFILEAIOLIMITS AioLimits;
RT_ZERO(AioLimits);
RTTESTI_CHECK_RC(rc = RTFileAioGetLimits(&AioLimits), VINF_SUCCESS);
if (RT_SUCCESS(rc))
{
RTTestSub(g_hTest, "Write");
RTFILE hFile;
RTTESTI_CHECK_RC(rc = RTFileOpen(&hFile, "tstFileAio#1.tst",
RTFILE_O_READWRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE | RTFILE_O_ASYNC_IO),
VINF_SUCCESS);
if (RT_SUCCESS(rc))
{
uint8_t *pbTestBuf = (uint8_t *)RTTestGuardedAllocTail(g_hTest, TSTFILEAIO_BUFFER_SIZE);
for (unsigned i = 0; i < TSTFILEAIO_BUFFER_SIZE; i++)
pbTestBuf[i] = i % 256;
uint32_t cReqsMax = AioLimits.cReqsOutstandingMax < TSTFILEAIO_MAX_REQS_IN_FLIGHT
? AioLimits.cReqsOutstandingMax
: TSTFILEAIO_MAX_REQS_IN_FLIGHT;
/* Basic write test. */
RTTestIPrintf(RTTESTLVL_ALWAYS, "Preparing test file, this can take some time and needs quite a bit of harddisk space...\n");
tstFileAioTestReadWriteBasic(hFile, true /*fWrite*/, pbTestBuf, TSTFILEAIO_BUFFER_SIZE, 100*_1M, cReqsMax);
/* Reopen the file before doing the next test. */
RTTESTI_CHECK_RC(RTFileClose(hFile), VINF_SUCCESS);
if (RTTestErrorCount(g_hTest) == 0)
{
RTTestSub(g_hTest, "Read/Write");
RTTESTI_CHECK_RC(rc = RTFileOpen(&hFile, "tstFileAio#1.tst",
RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_ASYNC_IO),
VINF_SUCCESS);
if (RT_SUCCESS(rc))
{
tstFileAioTestReadWriteBasic(hFile, false /*fWrite*/, pbTestBuf, TSTFILEAIO_BUFFER_SIZE, 100*_1M, cReqsMax);
RTFileClose(hFile);
}
}
/* Cleanup */
RTFileDelete("tstFileAio#1.tst");
}
}
/*
* Summary
*/
return RTTestSummaryAndDestroy(g_hTest);
}
示例9: main
int main()
{
/* How many integer test items should be created. */
static const size_t s_cTestCount = 1000;
RTTEST hTest;
RTEXITCODE rcExit = RTTestInitAndCreate("tstIprtList", &hTest);
if (rcExit)
return rcExit;
RTTestBanner(hTest);
/*
* Native types.
*/
uint8_t au8TestInts[s_cTestCount];
for (size_t i = 0; i < RT_ELEMENTS(au8TestInts); ++i)
au8TestInts[i] = (uint8_t)RTRandU32Ex(1, UINT8_MAX);
test1<RTCList, uint8_t, uint8_t, uint8_t>("ST: Native type", au8TestInts, RT_ELEMENTS(au8TestInts));
test1<RTCMTList, uint8_t, uint8_t, uint8_t>("MT: Native type", au8TestInts, RT_ELEMENTS(au8TestInts));
uint16_t au16TestInts[s_cTestCount];
for (size_t i = 0; i < RT_ELEMENTS(au16TestInts); ++i)
au16TestInts[i] = (uint16_t)RTRandU32Ex(1, UINT16_MAX);
test1<RTCList, uint16_t, uint16_t, uint16_t>("ST: Native type", au16TestInts, RT_ELEMENTS(au16TestInts));
test1<RTCMTList, uint16_t, uint16_t, uint16_t>("MT: Native type", au16TestInts, RT_ELEMENTS(au16TestInts));
uint32_t au32TestInts[s_cTestCount];
for (size_t i = 0; i < RT_ELEMENTS(au32TestInts); ++i)
au32TestInts[i] = RTRandU32Ex(1, UINT32_MAX);
test1<RTCList, uint32_t, uint32_t, uint32_t>("ST: Native type", au32TestInts, RT_ELEMENTS(au32TestInts));
test1<RTCMTList, uint32_t, uint32_t, uint32_t>("MT: Native type", au32TestInts, RT_ELEMENTS(au32TestInts));
/*
* Specialized type.
*/
uint64_t au64TestInts[s_cTestCount];
for (size_t i = 0; i < RT_ELEMENTS(au64TestInts); ++i)
au64TestInts[i] = RTRandU64Ex(1, UINT64_MAX);
test1<RTCList, uint64_t, uint64_t, uint64_t>("ST: Specialized type", au64TestInts, RT_ELEMENTS(au64TestInts));
test1<RTCMTList, uint64_t, uint64_t, uint64_t>("MT: Specialized type", au64TestInts, RT_ELEMENTS(au64TestInts));
/*
* Big size type (translate to internal pointer list).
*/
test1<RTCList, RTCString, RTCString *, const char *>("ST: Class type", g_apszTestStrings, RT_ELEMENTS(g_apszTestStrings));
test1<RTCMTList, RTCString, RTCString *, const char *>("MT: Class type", g_apszTestStrings, RT_ELEMENTS(g_apszTestStrings));
/*
* Multi-threading test.
*/
test2();
/*
* Summary.
*/
return RTTestSummaryAndDestroy(hTest);
}
示例10: main
int main(int argc, char **argv)
{
RT_NOREF_PV(argv);
int rc = RTTestInitAndCreate("tstRTCritSectRw", &g_hTest);
if (rc)
return 1;
RTTestBanner(g_hTest);
if (Test1())
{
RTCPUID cCores = RTMpGetOnlineCoreCount();
if (argc == 1)
{
TestNegative();
/* threads, seconds, writePercent, yield, quiet */
Test4( 1, 1, 0, true, false);
Test4( 1, 1, 1, true, false);
Test4( 1, 1, 5, true, false);
Test4( 2, 1, 3, true, false);
Test4( 10, 1, 5, true, false);
Test4( 10, 10, 10, false, false);
if (cCores > 1)
{
RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "benchmarking (%u CPU cores)...\n", cCores);
for (unsigned cThreads = 1; cThreads < 32; cThreads++)
Test4(cThreads, 2, 1, false, true);
}
else
RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "skipping benchmarking (only %u core available)\n", cCores);
/** @todo add a testcase where some stuff times out. */
}
else
{
if (cCores > 1)
{
/* threads, seconds, writePercent, yield, quiet */
RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "benchmarking (%u CPU cores)...\n", cCores);
Test4( 1, 3, 1, false, true);
Test4( 1, 3, 1, false, true);
Test4( 1, 3, 1, false, true);
Test4( 2, 3, 1, false, true);
Test4( 2, 3, 1, false, true);
Test4( 2, 3, 1, false, true);
Test4( 3, 3, 1, false, true);
Test4( 3, 3, 1, false, true);
Test4( 3, 3, 1, false, true);
}
else
RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "skipping benchmarking (only %u core available)\n", cCores);
}
}
return RTTestSummaryAndDestroy(g_hTest);
}
示例11: main
int main()
{
RTEXITCODE rcExit = RTTestInitAndCreate("tstRTThreadExecutionTime", &g_hTest);
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
test1();
return RTTestSummaryAndDestroy(g_hTest);
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:9,代码来源:tstRTThreadExecutionTime.cpp
示例12: main
int main(int argc, char **argv)
{
RTEXITCODE rcExit = RTTestInitAndCreate(RTPathFilename(argv[0]),
&g_hTest);
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
RTTestBanner(g_hTest);
testAPI(g_hTest);
return RTTestSummaryAndDestroy(g_hTest);
}
示例13: main
int main()
{
RTTEST hTest;
int rc = RTTestInitAndCreate("tstRTFileAppend-1", &hTest);
if (rc)
return rc;
RTTestBanner(hTest);
tstFileAppend1(hTest);
RTFileDelete("tstFileAppend-1.tst");
return RTTestSummaryAndDestroy(hTest);
}
示例14: mainParent
/**
* The parent main routine.
* @param argv0 The executable name (or whatever).
*/
static int mainParent(const char *argv0)
{
/*
* Init.
*/
RTTEST hTest;
int rc = RTTestInitAndCreate("tstSupSem-Zombie", &hTest);
if (rc)
return rc;
RTTestBanner(hTest);
/*
* Spin of the child process which may or may not turn into a zombie
*/
for (uint32_t iPass = 0; iPass < 32; iPass++)
{
RTTestSubF(hTest, "Pass %u", iPass);
RTPROCESS hProcess;
const char *apszArgs[3] = { argv0, "--child", NULL };
RTTESTI_CHECK_RC_OK(rc = RTProcCreate(argv0, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, &hProcess));
if (RT_SUCCESS(rc))
{
/*
* Wait for 60 seconds then give up.
*/
RTPROCSTATUS Status;
uint64_t StartTS = RTTimeMilliTS();
for (;;)
{
rc = RTProcWait(hProcess, RTPROCWAIT_FLAGS_NOBLOCK, &Status);
if (RT_SUCCESS(rc))
break;
uint64_t cElapsed = RTTimeMilliTS() - StartTS;
if (cElapsed > 60*1000)
break;
RTThreadSleep(cElapsed < 60 ? 30 : cElapsed < 200 ? 10 : 100);
}
RTTESTI_CHECK_RC_OK(rc);
if ( RT_SUCCESS(rc)
&& ( Status.enmReason != RTPROCEXITREASON_NORMAL
|| Status.iStatus != 0))
{
RTTestIFailed("child %d (%#x) reason %d\n", Status.iStatus, Status.iStatus, Status.enmReason);
rc = VERR_PERMISSION_DENIED;
}
}
/* one zombie process is enough. */
if (RT_FAILURE(rc))
break;
}
return RTTestSummaryAndDestroy(hTest);
}
示例15: main
int main(int argc, char **argv)
{
RTTEST hTest;
RTEXITCODE rcExit = RTTestInitAndCreate("tstRTDarwinMachKernel", &hTest);
if (rcExit != RTEXITCODE_SUCCESS)
return rcExit;
RTTestBanner(hTest);
dotest();
return RTTestSummaryAndDestroy(hTest);
}