Changeset 87228 in vbox for trunk/src/VBox/Runtime/testcase/tstRTInlineAsm.cpp
- Timestamp:
- Jan 12, 2021 1:56:20 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTInlineAsm.cpp
r87221 r87228 99 99 } while (0) 100 100 101 /** 102 * Calls a worker function with different worker variable storage types. 103 */ 104 #define DO_SIMPLE_TEST_NO_SUB_NO_STACK(a_WorkerFunction, type) \ 105 do \ 106 { \ 107 type *pVar = (type *)RTTestGuardedAllocHead(g_hTest, sizeof(type)); \ 108 RTTEST_CHECK_BREAK(g_hTest, pVar); \ 109 a_WorkerFunction(pVar); \ 110 RTTestGuardedFree(g_hTest, pVar); \ 111 \ 112 pVar = (type *)RTTestGuardedAllocTail(g_hTest, sizeof(type)); \ 113 RTTEST_CHECK_BREAK(g_hTest, pVar); \ 114 a_WorkerFunction(pVar); \ 115 RTTestGuardedFree(g_hTest, pVar); \ 116 } while (0) 117 118 119 /** 120 * Calls a worker function with different worker variable storage types. 121 */ 122 #define DO_SIMPLE_TEST_NO_SUB(a_WorkerFunction, type) \ 123 do \ 124 { \ 125 type StackVar; \ 126 a_WorkerFunction(&StackVar); \ 127 DO_SIMPLE_TEST_NO_SUB_NO_STACK(a_WorkerFunction, type); \ 128 } while (0) 101 129 102 130 /** … … 107 135 { \ 108 136 RTTestISub(#name); \ 109 type StackVar; \ 110 tst ## name ## Worker(&StackVar); \ 111 \ 112 type *pVar = (type *)RTTestGuardedAllocHead(g_hTest, sizeof(type)); \ 113 RTTEST_CHECK_BREAK(g_hTest, pVar); \ 114 tst ## name ## Worker(pVar); \ 115 RTTestGuardedFree(g_hTest, pVar); \ 116 \ 117 pVar = (type *)RTTestGuardedAllocTail(g_hTest, sizeof(type)); \ 118 RTTEST_CHECK_BREAK(g_hTest, pVar); \ 119 tst ## name ## Worker(pVar); \ 120 RTTestGuardedFree(g_hTest, pVar); \ 137 DO_SIMPLE_TEST_NO_SUB(tst ## name ## Worker, type); \ 121 138 } while (0) 122 139 … … 2126 2143 if (pPage->ab[i]) 2127 2144 RTTestFailed(g_hTest, "ASMMemZeroPage didn't clear byte at offset %#x!\n", i); 2145 if (ASMMemIsZeroPage(pPage) != true) 2146 RTTestFailed(g_hTest, "ASMMemIsZeroPage returns false after ASMMemZeroPage!\n"); 2147 if (ASMMemFirstMismatchingU32(pPage, sizeof(pPage), 0) != NULL) 2148 RTTestFailed(g_hTest, "ASMMemFirstMismatchingU32(,,0) returns non-NULL after ASMMemZeroPage!\n"); 2128 2149 } 2129 2150 } … … 2132 2153 static void tstASMMemZeroPage(void) 2133 2154 { 2134 DO_SIMPLE_TEST(ASMMemZeroPage, TSTPAGE); 2155 RTTestISub("ASMMemZeroPage"); 2156 DO_SIMPLE_TEST_NO_SUB_NO_STACK(tstASMMemZeroPageWorker, TSTPAGE); 2135 2157 } 2136 2158 … … 2293 2315 2294 2316 2317 typedef struct TSTBUF32 { uint32_t au32[384]; } TSTBUF32; 2318 2319 DECLINLINE(void) tstASMMemZero32Worker(TSTBUF32 *pBuf) 2320 { 2321 ASMMemZero32(pBuf, sizeof(*pBuf)); 2322 for (unsigned i = 0; i < RT_ELEMENTS(pBuf->au32); i++) 2323 if (pBuf->au32[i]) 2324 RTTestFailed(g_hTest, "ASMMemZero32 didn't clear dword at index %#x!\n", i); 2325 if (ASMMemFirstNonZero(pBuf, sizeof(*pBuf)) != NULL) 2326 RTTestFailed(g_hTest, "ASMMemFirstNonZero return non-NULL after ASMMemZero32\n"); 2327 if (!ASMMemIsZero(pBuf, sizeof(*pBuf))) 2328 RTTestFailed(g_hTest, "ASMMemIsZero return false after ASMMemZero32\n"); 2329 2330 memset(pBuf, 0xfe, sizeof(*pBuf)); 2331 ASMMemZero32(pBuf, sizeof(*pBuf)); 2332 for (unsigned i = 0; i < RT_ELEMENTS(pBuf->au32); i++) 2333 if (pBuf->au32[i]) 2334 RTTestFailed(g_hTest, "ASMMemZero32 didn't clear dword at index %#x!\n", i); 2335 if (ASMMemFirstNonZero(pBuf, sizeof(*pBuf)) != NULL) 2336 RTTestFailed(g_hTest, "ASMMemFirstNonZero return non-NULL after ASMMemZero32\n"); 2337 if (!ASMMemIsZero(pBuf, sizeof(*pBuf))) 2338 RTTestFailed(g_hTest, "ASMMemIsZero return false after ASMMemZero32\n"); 2339 } 2340 2341 2295 2342 void tstASMMemZero32(void) 2296 2343 { 2297 RTTestSub(g_hTest, "ASMMem Fill32");2344 RTTestSub(g_hTest, "ASMMemZero32"); 2298 2345 2299 2346 struct … … 2334 2381 if (Buf3.abPage[i]) 2335 2382 RTTestFailed(g_hTest, "ASMMemZero32 didn't clear byte at offset %#x!\n", i); 2336 } 2337 2383 2384 DO_SIMPLE_TEST_NO_SUB(tstASMMemZero32Worker, TSTBUF32); 2385 } 2386 2387 2388 DECLINLINE(void) tstASMMemFill32Worker(TSTBUF32 *pBuf) 2389 { 2390 ASMMemFill32(pBuf, sizeof(*pBuf), UINT32_C(0xf629bce1)); 2391 for (unsigned i = 0; i < RT_ELEMENTS(pBuf->au32); i++) 2392 if (pBuf->au32[i] != UINT32_C(0xf629bce1)) 2393 RTTestFailed(g_hTest, "ASMMemFill32 didn't set dword at index %#x correctly!\n", i); 2394 if (ASMMemFirstMismatchingU32(pBuf, sizeof(*pBuf), UINT32_C(0xf629bce1)) != NULL) 2395 RTTestFailed(g_hTest, "ASMMemFirstMismatchingU32(,,UINT32_C(0xf629bce1)) returns non-NULL after ASMMemFill32!\n"); 2396 2397 memset(pBuf, 0xfe, sizeof(*pBuf)); 2398 ASMMemFill32(pBuf, sizeof(*pBuf), UINT32_C(0x12345678)); 2399 for (unsigned i = 0; i < RT_ELEMENTS(pBuf->au32); i++) 2400 if (pBuf->au32[i] != UINT32_C(0x12345678)) 2401 RTTestFailed(g_hTest, "ASMMemFill32 didn't set dword at index %#x correctly!\n", i); 2402 if (ASMMemFirstMismatchingU32(pBuf, sizeof(*pBuf), UINT32_C(0x12345678)) != NULL) 2403 RTTestFailed(g_hTest, "ASMMemFirstMismatchingU32(,,UINT32_C(0x12345678)) returns non-NULL after ASMMemFill32!\n"); 2404 } 2338 2405 2339 2406 void tstASMMemFill32(void) … … 2388 2455 if (Buf3.au32Page[i] != 0xf00dd00f) 2389 2456 RTTestFailed(g_hTest, "ASMMemFill32 %#x: %#x exepcted %#x\n", i, Buf3.au32Page[i], 0xf00dd00f); 2457 2458 DO_SIMPLE_TEST_NO_SUB(tstASMMemFill32Worker, TSTBUF32); 2459 } 2460 2461 2462 void tstASMProbe(RTTEST hTest) 2463 { 2464 RTTestSub(hTest, "ASMProbeReadByte/Buffer"); 2465 2466 uint8_t b = 42; 2467 RTTESTI_CHECK(ASMProbeReadByte(&b) == 42); 2468 ASMProbeReadBuffer(&b, sizeof(b)); 2469 2470 for (uint32_t cPages = 1; cPages < 16; cPages++) 2471 { 2472 uint8_t *pbBuf1 = (uint8_t *)RTTestGuardedAllocHead(hTest, cPages * PAGE_SIZE); 2473 uint8_t *pbBuf2 = (uint8_t *)RTTestGuardedAllocTail(hTest, cPages * PAGE_SIZE); 2474 RTTESTI_CHECK_RETV(pbBuf1 && pbBuf2); 2475 2476 memset(pbBuf1, 0xf6, cPages * PAGE_SIZE); 2477 memset(pbBuf2, 0x42, cPages * PAGE_SIZE); 2478 2479 RTTESTI_CHECK(ASMProbeReadByte(&pbBuf1[cPages * PAGE_SIZE - 1]) == 0xf6); 2480 RTTESTI_CHECK(ASMProbeReadByte(&pbBuf2[cPages * PAGE_SIZE - 1]) == 0x42); 2481 RTTESTI_CHECK(ASMProbeReadByte(&pbBuf1[0]) == 0xf6); 2482 RTTESTI_CHECK(ASMProbeReadByte(&pbBuf2[0]) == 0x42); 2483 2484 ASMProbeReadBuffer(pbBuf1, cPages * PAGE_SIZE); 2485 ASMProbeReadBuffer(pbBuf2, cPages * PAGE_SIZE); 2486 } 2390 2487 } 2391 2488 … … 2574 2671 static int64_t volatile s_i64; 2575 2672 unsigned i; 2576 const unsigned cRounds = _ 2M; /* Must be multiple of 8 */2673 const unsigned cRounds = _16M; /* Must be multiple of 8 */ 2577 2674 uint64_t u64Elapsed; 2578 2675 … … 2769 2866 tstASMMemZero32(); 2770 2867 tstASMMemFill32(); 2868 tstASMProbe(g_hTest); 2771 2869 2772 2870 tstASMMisc();
Note:
See TracChangeset
for help on using the changeset viewer.