本文整理汇总了C++中RTTESTI_CHECK_RC_RETV函数的典型用法代码示例。如果您正苦于以下问题:C++ RTTESTI_CHECK_RC_RETV函数的具体用法?C++ RTTESTI_CHECK_RC_RETV怎么用?C++ RTTESTI_CHECK_RC_RETV使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTTESTI_CHECK_RC_RETV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doUnicastTest
/**
* Performs a simple unicast test.
*
* @param pThis The test instance.
* @param fHeadGuard Whether to use a head or tail guard.
*/
static void doUnicastTest(PTSTSTATE pThis, bool fHeadGuard)
{
static uint16_t const s_au16Frame[7] = { /* dst:*/ 0x8086, 0, 0, /*src:*/0x8086, 0, 1, 0x0800 };
RTTESTI_CHECK_RC_RETV(tstIntNetSendBuf(&pThis->pBuf1->Send, pThis->hIf1,
g_pSession, s_au16Frame, sizeof(s_au16Frame)),
VINF_SUCCESS);
/* No echo, please */
RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf1, g_pSession, 1), VERR_TIMEOUT);
/* The other interface should see it though. But Wait should only return once, thank you. */
RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf0, g_pSession, 1), VINF_SUCCESS);
RTTESTI_CHECK_RC_RETV(IntNetR0IfWait(pThis->hIf0, g_pSession, 0), VERR_TIMEOUT);
/* Receive the data. */
const unsigned cbExpect = RT_ALIGN(sizeof(s_au16Frame) + sizeof(INTNETHDR), sizeof(INTNETHDR));
RTTESTI_CHECK_MSG(IntNetRingGetReadable(&pThis->pBuf0->Recv) == cbExpect,
("%#x vs. %#x\n", IntNetRingGetReadable(&pThis->pBuf0->Recv), cbExpect));
void *pvBuf;
RTTESTI_CHECK_RC_OK_RETV(RTTestGuardedAlloc(g_hTest, sizeof(s_au16Frame), 1, fHeadGuard, &pvBuf));
uint32_t cb;
RTTESTI_CHECK_MSG_RETV((cb = IntNetRingReadAndSkipFrame(&pThis->pBuf0->Recv, pvBuf)) == sizeof(s_au16Frame),
("%#x vs. %#x\n", cb, sizeof(s_au16Frame)));
if (memcmp(pvBuf, &s_au16Frame, sizeof(s_au16Frame)))
RTTestIFailed("Got invalid data!\n"
"received: %.*Rhxs\n"
"expected: %.*Rhxs\n",
cb, pvBuf, sizeof(s_au16Frame), s_au16Frame);
}
示例2: tstRTCreateProcEx5
static void tstRTCreateProcEx5(const char *pszUser, const char *pszPassword)
{
RTTestISubF("As user \"%s\" with password \"%s\"", pszUser, pszPassword);
const char * apszArgs[3] =
{
"test", /* user name */
"--testcase-child-5",
NULL
};
RTPROCESS hProc;
/* Test for invalid logons. */
RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
NULL, NULL, "non-existing-user", "wrong-password", &hProc), VERR_AUTHENTICATION_FAILURE);
/* Test for invalid application. */
RTTESTI_CHECK_RC_RETV(RTProcCreateEx("non-existing-app", apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
NULL, NULL, NULL, NULL, &hProc), VERR_FILE_NOT_FOUND);
/* Test a (hopefully) valid user/password logon (given by parameters of this function). */
RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
NULL, NULL, pszUser, pszPassword, &hProc), VINF_SUCCESS);
RTPROCSTATUS ProcStatus = { -1, RTPROCEXITREASON_ABEND };
RTTESTI_CHECK_RC(RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS);
if (ProcStatus.enmReason != RTPROCEXITREASON_NORMAL || ProcStatus.iStatus != 0)
RTTestIFailed("enmReason=%d iStatus=%d", ProcStatus.enmReason, ProcStatus.iStatus);
else
RTTestIPassed(NULL);
}
示例3: test1
static void test1(void)
{
RTTestISub("Three threads");
/*
* Create the threads and let them block on the event multi semaphore.
*/
RTSEMEVENTMULTI hSem;
RTTESTI_CHECK_RC_RETV(RTSemEventMultiCreate(&hSem), VINF_SUCCESS);
RTTHREAD hThread2;
RTTESTI_CHECK_RC_RETV(RTThreadCreate(&hThread2, test1Thread2, &hSem, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "test2"), VINF_SUCCESS);
RTThreadSleep(100);
RTTHREAD hThread1;
RTTESTI_CHECK_RC_RETV(RTThreadCreate(&hThread1, test1Thread1, &hSem, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "test1"), VINF_SUCCESS);
/* Force first thread (which has a timeout of 1 second) to timeout in the
* first wait, and the second wait will succeed. */
RTTESTI_CHECK_RC(RTThreadSleep(1500), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTSemEventMultiSignal(hSem), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTThreadWait(hThread1, 5000, NULL), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTThreadWait(hThread2, 5000, NULL), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTSemEventMultiDestroy(hSem), VINF_SUCCESS);
}
示例4: tstRTPipe5
static void tstRTPipe5(void)
{
RTTestISub("Inherit non-standard pipe handle, read end");
char szPathSelf[RTPATH_MAX];
RTTESTI_CHECK_RETV(RTProcGetExecutablePath(szPathSelf, sizeof(szPathSelf)) == szPathSelf);
RTPIPE hPipeR;
RTPIPE hPipeW;
RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_READ), VINF_SUCCESS);
RTHCINTPTR hNative = RTPipeToNative(hPipeR);
RTTESTI_CHECK_RETV(hNative != -1);
char szNative[64];
RTStrPrintf(szNative, sizeof(szNative), "%RHi", hNative);
const char *papszArgs[4] = { szPathSelf, "--child-5", szNative, NULL };
RTPROCESS hChild;
RTTESTI_CHECK_RC_RETV(RTProcCreate(szPathSelf, papszArgs, RTENV_DEFAULT, 0 /*fFlags*/, &hChild), VINF_SUCCESS);
RTTESTI_CHECK_RC_RETV(RTPipeClose(hPipeR), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTPipeWriteBlocking(hPipeW, g_szTest5Message, sizeof(g_szTest5Message) - 1, NULL), VINF_SUCCESS);
int rc;
RTTESTI_CHECK_RC(rc = RTPipeClose(hPipeW), VINF_SUCCESS);
if (RT_FAILURE(rc))
RTTESTI_CHECK_RC(RTProcTerminate(hChild), VINF_SUCCESS);
RTPROCSTATUS ProcStatus;
RTTESTI_CHECK_RC(rc = RTProcWait(hChild, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS);
if (RT_FAILURE(rc))
return;
RTTESTI_CHECK( ProcStatus.enmReason == RTPROCEXITREASON_NORMAL
&& ProcStatus.iStatus == 0);
}
示例5: tst2
/**
* Check hash and memory performance.
*/
static void tst2(void)
{
RTTestISub("Hash performance");
/*
* Generate test strings using a specific pseudo random generator.
*/
size_t cbStrings = 0;
char *apszTests[8192];
RTRAND hRand;
RTTESTI_CHECK_RC_RETV(RTRandAdvCreateParkMiller(&hRand), VINF_SUCCESS);
for (uint32_t i = 0; i < 8192; i++)
{
char szBuf[8192];
uint32_t cch = RTRandAdvU32Ex(hRand, 3, sizeof(szBuf) - 1);
RTRandAdvBytes(hRand, szBuf, cch);
szBuf[cch] = '\0';
for (uint32_t off = 0; off < cch; off++)
{
uint8_t b = szBuf[off];
b &= 0x7f;
if (!b || b == 0x7f)
b = ' ';
else if (RTLocCIsCntrl(b) && b != '\n' && b != '\r' && b != '\t')
b += 0x30;
szBuf[off] = b;
}
apszTests[i] = (char *)RTMemDup(szBuf, cch + 1);
RTTESTI_CHECK_RETV(apszTests[i] != NULL);
cbStrings += cch + 1;
}
RTRandAdvDestroy(hRand);
RTTestIValue("Average string", cbStrings / RT_ELEMENTS(apszTests), RTTESTUNIT_BYTES);
/*
* Test new insertion first time around.
*/
RTSTRCACHE hStrCache;
RTTESTI_CHECK_RC_RETV(RTStrCacheCreate(&hStrCache, "hash performance"), VINF_SUCCESS);
uint64_t nsTsStart = RTTimeNanoTS();
for (uint32_t i = 0; i < RT_ELEMENTS(apszTests); i++)
RTTESTI_CHECK_RETV(RTStrCacheEnter(hStrCache, apszTests[i]) != NULL);
uint64_t cNsElapsed = RTTimeNanoTS() - nsTsStart;
RTTestIValue("First insert", cNsElapsed / RT_ELEMENTS(apszTests), RTTESTUNIT_NS_PER_CALL);
/*
* Insert existing strings.
*/
nsTsStart = RTTimeNanoTS();
for (uint32_t i = 0; i < 8192; i++)
RTTESTI_CHECK(RTStrCacheEnter(hStrCache, apszTests[i]) != NULL);
cNsElapsed = RTTimeNanoTS() - nsTsStart;
RTTestIValue("Duplicate insert", cNsElapsed / RT_ELEMENTS(apszTests), RTTESTUNIT_NS_PER_CALL);
tstShowStats(hStrCache);
RTTESTI_CHECK_RC(RTStrCacheDestroy(hStrCache), VINF_SUCCESS);
}
示例6: tstCheckNativeMsCrtToArgv
static void tstCheckNativeMsCrtToArgv(const char *pszCmdLine, int cExpectedArgs, const char * const *papszExpectedArgs)
{
#ifdef RT_OS_WINDOWS
/*
* Resolve APIs.
*/
static void *(__stdcall * s_pfnLocalFree)(void *pvFree);
static PRTUTF16 *(__stdcall * s_pfnCommandLineToArgvW)(PCRTUTF16 pwszCmdLine, int *pcArgs);
if (!s_pfnCommandLineToArgvW)
{
*(void **)&s_pfnLocalFree = RTLdrGetSystemSymbol("kernel32.dll", "LocalFree");
RTTESTI_CHECK_RETV(s_pfnLocalFree != NULL);
*(void **)&s_pfnCommandLineToArgvW = RTLdrGetSystemSymbol("shell32.dll", "CommandLineToArgvW");
RTTESTI_CHECK_RETV(s_pfnCommandLineToArgvW != NULL);
}
/*
* Calc expected arguments if needed.
*/
if (cExpectedArgs == -1)
for (cExpectedArgs = 0; papszExpectedArgs[cExpectedArgs]; cExpectedArgs++)
{ /* nothing */ }
/*
* Convert input command line to UTF-16 and call native API.
*/
RTUTF16 wszCmdLine[1024];
PRTUTF16 pwszCmdLine = &wszCmdLine[1];
RTTESTI_CHECK_RC_RETV(RTStrToUtf16Ex(pszCmdLine, RTSTR_MAX, &pwszCmdLine, 1023, NULL), VINF_SUCCESS);
wszCmdLine[0] = ' ';
int cArgs = -2;
PRTUTF16 *papwszArgs = s_pfnCommandLineToArgvW(wszCmdLine, &cArgs);
/*
* Check the result.
*/
if (cArgs - 1 != cExpectedArgs)
RTTestIFailed("Native returns cArgs=%d, expected %d (cmdline=|%s|)", cArgs - 1, cExpectedArgs, pszCmdLine);
int cArgsCheck = RT_MIN(cArgs - 1, cExpectedArgs);
for (int i = 0; i < cArgsCheck; i++)
{
char *pszArg = NULL;
RTTESTI_CHECK_RC_RETV(RTUtf16ToUtf8(papwszArgs[i + 1], &pszArg), VINF_SUCCESS);
if (strcmp(pszArg, papszExpectedArgs[i]))
RTTestIFailed("Native returns argv[%i]='%s', expected '%s' (cmdline=|%s|)",
i, pszArg, papszExpectedArgs[i], pszCmdLine);
RTStrFree(pszArg);
}
if (papwszArgs)
s_pfnLocalFree(papwszArgs);
#else
NOREF(pszCmdLine);
NOREF(cExpectedArgs);
NOREF(papszExpectedArgs);
#endif
}
示例7: tstRTCreateProcEx2
static void tstRTCreateProcEx2(const char *pszAsUser, const char *pszPassword)
{
RTTestISub("Standard Err");
RTPIPE hPipeR, hPipeW;
RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, RTPIPE_C_INHERIT_WRITE), VINF_SUCCESS);
const char * apszArgs[3] =
{
"non-existing-non-executable-file",
"--testcase-child-2",
NULL
};
RTHANDLE Handle;
Handle.enmType = RTHANDLETYPE_PIPE;
Handle.u.hPipe = hPipeW;
RTPROCESS hProc;
RTTESTI_CHECK_RC_RETV(RTProcCreateEx(g_szExecName, apszArgs, RTENV_DEFAULT, 0 /*fFlags*/, NULL,
NULL, &Handle, pszAsUser, pszPassword, &hProc), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
char szOutput[_4K];
size_t offOutput = 0;
for (;;)
{
size_t cbLeft = sizeof(szOutput) - 1 - offOutput;
RTTESTI_CHECK(cbLeft > 0);
if (cbLeft == 0)
break;
size_t cbRead;
int rc = RTPipeReadBlocking(hPipeR, &szOutput[offOutput], cbLeft, &cbRead);
if (RT_FAILURE(rc))
{
RTTESTI_CHECK_RC(rc, VERR_BROKEN_PIPE);
break;
}
offOutput += cbRead;
}
szOutput[offOutput] = '\0';
RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
RTPROCSTATUS ProcStatus = { -1, RTPROCEXITREASON_ABEND };
RTTESTI_CHECK_RC(RTProcWait(hProc, RTPROCWAIT_FLAGS_BLOCK, &ProcStatus), VINF_SUCCESS);
RTThreadSleep(10);
if (ProcStatus.enmReason != RTPROCEXITREASON_NORMAL || ProcStatus.iStatus != 0)
RTTestIFailed("enmReason=%d iStatus=%d", ProcStatus.enmReason, ProcStatus.iStatus);
else if ( offOutput != sizeof("howdy") - 1
|| strcmp(szOutput, "howdy"))
RTTestIFailed("wrong output: \"%s\" (len=%u)", szOutput, offOutput);
else
RTTestIPassed(NULL);
}
示例8: tst3
/**
* Test automatic cleanup upon destruction.
*/
static void tst3(void)
{
RTTestISub("Destroy non-empty pool");
/*
* Nothing freed.
*/
RTMEMPOOL hMemPool;
RTTESTI_CHECK_RC_RETV(RTMemPoolCreate(&hMemPool, "test 3a"), VINF_SUCCESS);
RTTESTI_CHECK_RETV(RTMemPoolAlloc(hMemPool, 10));
RTTESTI_CHECK_RETV(RTMemPoolAlloc(hMemPool, 20));
RTTESTI_CHECK_RETV(RTMemPoolAlloc(hMemPool, 40));
RTTESTI_CHECK_RETV(RTMemPoolAlloc(hMemPool, 80));
RTTESTI_CHECK_RC_RETV(RTMemPoolDestroy(hMemPool), VINF_SUCCESS);
/*
* Pseudo random freeing to test list maintenance.
*/
RTRAND hRand;
RTTESTI_CHECK_RC_OK_RETV(RTRandAdvCreateParkMiller(&hRand));
for (uint32_t i = 0; i < 10; i++)
{
RTTESTI_CHECK_RC_RETV(RTMemPoolCreate(&hMemPool, "test 3b"), VINF_SUCCESS);
void *apvHistory[256];
RT_ZERO(apvHistory);
uint32_t cBlocks = 0;
uint32_t j;
for (j = 0; j < RT_ELEMENTS(apvHistory) - i * 7; j++)
{
RTTESTI_CHECK_RETV(apvHistory[j] = RTMemPoolAlloc(hMemPool, j));
memset(apvHistory[j], 'a', j);
cBlocks++;
if (RTRandAdvU32Ex(hRand, 0, 4) == 4)
{
uint32_t iFree = RTRandAdvU32Ex(hRand, 0, j);
cBlocks -= apvHistory[iFree] != NULL;
RTTESTI_CHECK_RETV(RTMemPoolRelease(hMemPool, apvHistory[iFree]) == 0);
apvHistory[iFree] = NULL;
}
}
RTTESTI_CHECK_RC_RETV(RTMemPoolDestroy(hMemPool), VINF_SUCCESS);
RTTestIPrintf(RTTESTLVL_INFO, "cBlocks=%u j=%u\n", cBlocks, j);
}
RTRandAdvDestroy(hRand);
}
示例9: tst2
static void tst2(void)
{
RTTestISub("RTGetOptArgvToString / MS_CRT");
for (size_t i = 0; i < RT_ELEMENTS(g_aMscCrtTests); i++)
{
char *pszCmdLine = NULL;
int rc = RTGetOptArgvToString(&pszCmdLine, g_aMscCrtTests[i].apszArgs, RTGETOPTARGV_CNV_QUOTE_MS_CRT);
RTTESTI_CHECK_RC_RETV(rc, VINF_SUCCESS);
if (!strcmp(g_aMscCrtTests[i].pszCmdLine, pszCmdLine))
tstCheckNativeMsCrtToArgv(pszCmdLine, -1, g_aMscCrtTests[i].apszArgs);
else
RTTestIFailed("g_aTest[%i] failed:\n"
" got '%s'\n"
" expected '%s'\n",
i, pszCmdLine, g_aMscCrtTests[i].pszCmdLine);
RTStrFree(pszCmdLine);
}
for (size_t i = 0; i < RT_ELEMENTS(g_aTests); i++)
{
char *pszCmdLine = NULL;
int rc = RTGetOptArgvToString(&pszCmdLine, g_aTests[i].apszArgs, RTGETOPTARGV_CNV_QUOTE_MS_CRT);
RTTESTI_CHECK_RC_RETV(rc, VINF_SUCCESS);
if (!strcmp(g_aTests[i].pszOutMsCrt, pszCmdLine))
tstCheckNativeMsCrtToArgv(pszCmdLine, g_aTests[i].cArgs, g_aTests[i].apszArgs);
else
RTTestIFailed("g_aTests[%i] failed:\n"
" got |%s|\n"
" expected |%s|\n",
i, pszCmdLine, g_aTests[i].pszOutMsCrt);
RTStrFree(pszCmdLine);
}
RTTestISub("RTGetOptArgvToString / BOURNE_SH");
for (size_t i = 0; i < RT_ELEMENTS(g_aTests); i++)
{
char *pszCmdLine = NULL;
int rc = RTGetOptArgvToString(&pszCmdLine, g_aTests[i].apszArgs, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
RTTESTI_CHECK_RC_RETV(rc, VINF_SUCCESS);
if (strcmp(g_aTests[i].pszOutBourneSh, pszCmdLine))
RTTestIFailed("g_aTests[%i] failed:\n"
" got |%s|\n"
" expected |%s|\n",
i, pszCmdLine, g_aTests[i].pszOutBourneSh);
RTStrFree(pszCmdLine);
}
}
示例10: test2
/**
* Does a multi-threading list test. Several list additions, reading, replacing
* and erasing are done simultaneous.
*
*/
static void test2()
{
RTTestISubF("MT test with 6 threads (%u tests per thread).", MTTESTITEMS);
int rc;
MTTESTLISTTYPE<MTTESTTYPE> testList;
RTTHREAD ahThreads[6];
static PFNRTTHREAD apfnThreads[6] =
{
MtTest1ThreadProc, MtTest2ThreadProc, MtTest3ThreadProc, MtTest4ThreadProc, MtTest5ThreadProc, MtTest6ThreadProc
};
for (unsigned i = 0; i < RT_ELEMENTS(ahThreads); i++)
{
RTTESTI_CHECK_RC_RETV(RTThreadCreateF(&ahThreads[i], apfnThreads[i], &testList, 0,
RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "mttest%u", i), VINF_SUCCESS);
}
uint64_t tsMsDeadline = RTTimeMilliTS() + 60000;
for (unsigned i = 0; i < RT_ELEMENTS(ahThreads); i++)
{
uint64_t tsNow = RTTimeMilliTS();
uint32_t cWait = tsNow > tsMsDeadline ? 5000 : tsMsDeadline - tsNow;
RTTESTI_CHECK_RC(RTThreadWait(ahThreads[i], tsNow, NULL), VINF_SUCCESS);
}
RTTESTI_CHECK_RETV(testList.size() == MTTESTITEMS * 2);
for (size_t i = 0; i < testList.size(); ++i)
{
uint32_t a = testList.at(i);
RTTESTI_CHECK(a == 0x0 || a == 0xFFFFFFFF || a == 0xF0F0F0F0 || a == 0xFF00FF00);
}
}
示例11: test1
static void test1(const char *pszSubTest, const char *pszFilename)
{
int rc;
RTTestISub(pszSubTest);
RTFILE hFile;
rc = RTFileOpen(&hFile, pszFilename, RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN);
if (RT_FAILURE(rc))
{
if ( rc == VERR_ACCESS_DENIED
|| rc == VERR_PERMISSION_DENIED
|| rc == VERR_FILE_NOT_FOUND)
{
RTTestIPrintf(RTTESTLVL_ALWAYS, "Cannot access '%s', skipping.", pszFilename);
return;
}
RTTESTI_CHECK_RC_RETV(RTFileOpen(&hFile, pszFilename, RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN), VINF_SUCCESS);
}
uint64_t cbFile = UINT64_MAX - 42;
RTTESTI_CHECK_RC(rc = RTFileGetSize(hFile, &cbFile), VINF_SUCCESS);
if (RT_SUCCESS(rc))
{
RTTESTI_CHECK(cbFile != UINT64_MAX - 42);
RTTestIValue(pszSubTest, cbFile, RTTESTUNIT_BYTES);
}
RTFileClose(hFile);
RTTestISubDone();
}
示例12: tstRTPipe2
static void tstRTPipe2(void)
{
RTTestISub("Negative");
RTPIPE hPipeR = (RTPIPE)1;
RTPIPE hPipeW = (RTPIPE)1;
RTTESTI_CHECK_RC(RTPipeCreate(&hPipeR, &hPipeW, ~0), VERR_INVALID_PARAMETER);
RTTESTI_CHECK_RC(RTPipeCreate(NULL, &hPipeW, 0), VERR_INVALID_POINTER);
RTTESTI_CHECK_RC(RTPipeCreate(&hPipeR, NULL, 0), VERR_INVALID_POINTER);
RTTESTI_CHECK(hPipeR == (RTPIPE)1);
RTTESTI_CHECK(hPipeW == (RTPIPE)1);
RTTESTI_CHECK_RC_RETV(RTPipeCreate(&hPipeR, &hPipeW, 0), VINF_SUCCESS);
char abBuf[_4K];
size_t cbRead = ~(size_t)3;
RTTESTI_CHECK_RC(RTPipeRead(hPipeW, abBuf, 0, &cbRead), VERR_ACCESS_DENIED);
RTTESTI_CHECK_RC(RTPipeRead(hPipeW, abBuf, 1, &cbRead), VERR_ACCESS_DENIED);
RTTESTI_CHECK(cbRead == ~(size_t)3);
RTTESTI_CHECK_RC(RTPipeReadBlocking(hPipeW, abBuf, 0, NULL), VERR_ACCESS_DENIED);
RTTESTI_CHECK_RC(RTPipeReadBlocking(hPipeW, abBuf, 1, NULL), VERR_ACCESS_DENIED);
size_t cbWrite = ~(size_t)5;
RTTESTI_CHECK_RC(RTPipeWrite(hPipeR, "asdf", 0, &cbWrite), VERR_ACCESS_DENIED);
RTTESTI_CHECK_RC(RTPipeWrite(hPipeR, "asdf", 4, &cbWrite), VERR_ACCESS_DENIED);
RTTESTI_CHECK(cbWrite == ~(size_t)5);
RTTESTI_CHECK_RC(RTPipeWriteBlocking(hPipeR, "asdf", 0, NULL), VERR_ACCESS_DENIED);
RTTESTI_CHECK_RC(RTPipeWriteBlocking(hPipeR, "asdf", 4, NULL), VERR_ACCESS_DENIED);
RTTESTI_CHECK_RC(RTPipeFlush(hPipeR), VERR_ACCESS_DENIED);
RTTESTI_CHECK_RC(RTPipeClose(hPipeR), VINF_SUCCESS);
RTTESTI_CHECK_RC(RTPipeClose(hPipeW), VINF_SUCCESS);
}
示例13: dotest
static void dotest(void)
{
RTDBGKRNLINFO hKrnlInfo;
RTTESTI_CHECK_RC_RETV(RTR0DbgKrnlInfoOpen(&hKrnlInfo, 0), VINF_SUCCESS);
static const char * const s_apszSyms[] =
{
"ast_pending",
"cpu_interrupt",
"dtrace_register",
"dtrace_suspend",
"kext_alloc",
"kext_free",
"vm_map_protect"
};
for (unsigned i = 0; i < RT_ELEMENTS(s_apszSyms); i++)
{
void *pvValue = NULL;
int rc = RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, s_apszSyms[i], &pvValue);
RTTestIPrintf(RTTESTLVL_ALWAYS, "%Rrc %p %s\n", rc, pvValue, s_apszSyms[i]);
RTTESTI_CHECK_RC(rc, VINF_SUCCESS);
if (RT_SUCCESS(rc))
RTTESTI_CHECK_RC(RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, s_apszSyms[i], NULL), VINF_SUCCESS);
}
RTTESTI_CHECK_RC(RTR0DbgKrnlInfoQuerySymbol(hKrnlInfo, NULL, "no_such_symbol_name_really", NULL), VERR_SYMBOL_NOT_FOUND);
RTTESTI_CHECK(RTR0DbgKrnlInfoRelease(hKrnlInfo) == 0);
RTTESTI_CHECK(RTR0DbgKrnlInfoRelease(NIL_RTDBGKRNLINFO) == 0);
}
示例14: doGeneralTests
static void doGeneralTests(PCFGMNODE pRoot)
{
/* test multilevel node creation */
PCFGMNODE pChild = NULL;
RTTESTI_CHECK_RC_RETV(CFGMR3InsertNode(pRoot, "First/Second/Third//Final", &pChild), VINF_SUCCESS);
RTTESTI_CHECK_RETV(RT_VALID_PTR(pChild));
RTTESTI_CHECK(CFGMR3GetChild(pRoot, "First/Second/Third/Final") == pChild);
/*
* Boolean queries.
*/
RTTESTI_CHECK_RC(CFGMR3InsertInteger(pChild, "BoolValue", 1), VINF_SUCCESS);
bool f = false;
RTTESTI_CHECK_RC(CFGMR3QueryBool(pChild, "BoolValue", &f), VINF_SUCCESS);
RTTESTI_CHECK(f == true);
RTTESTI_CHECK_RC(CFGMR3QueryBool(pRoot, "BoolValue", &f), VERR_CFGM_VALUE_NOT_FOUND);
RTTESTI_CHECK_RC(CFGMR3QueryBool(NULL, "BoolValue", &f), VERR_CFGM_NO_PARENT);
RTTESTI_CHECK_RC(CFGMR3QueryBoolDef(pChild, "ValueNotFound", &f, true), VINF_SUCCESS);
RTTESTI_CHECK(f == true);
RTTESTI_CHECK_RC(CFGMR3QueryBoolDef(pChild, "ValueNotFound", &f, false), VINF_SUCCESS);
RTTESTI_CHECK(f == false);
RTTESTI_CHECK_RC(CFGMR3QueryBoolDef(NULL, "BoolValue", &f, true), VINF_SUCCESS);
RTTESTI_CHECK(f == true);
RTTESTI_CHECK_RC(CFGMR3QueryBoolDef(NULL, "BoolValue", &f, false), VINF_SUCCESS);
RTTESTI_CHECK(f == false);
}
示例15: benchmarkFileOpenClose
static void benchmarkFileOpenClose(void)
{
RTTestSub(g_hTest, "RTFileOpen + RTFileClose");
RTTESTI_CHECK_RC_RETV(benchmarkFileOpenCloseOp(g_szNotExitingFile), VERR_FILE_NOT_FOUND);
TIME_OP(benchmarkFileOpenCloseOp(g_szNotExitingFile), "RTFileOpen(g_szNotExitingFile)");
RTTESTI_CHECK_RC_RETV(benchmarkFileOpenCloseOp(g_szNotExitingFile), VERR_FILE_NOT_FOUND);
TIME_OP(benchmarkFileOpenCloseOp(g_szNotExitingFile), "RTFileOpen(g_szNotExitingFile)");
int rc = benchmarkFileOpenCloseOp(g_szNotExitingDirFile);
RTTESTI_CHECK_RETV(rc == VERR_PATH_NOT_FOUND || VERR_FILE_NOT_FOUND);
TIME_OP(benchmarkFileOpenCloseOp(g_szNotExitingDirFile), "RTFileOpen(g_szNotExitingDirFile)");
RTTestSubDone(g_hTest);
}