Changeset 93711 in vbox for trunk/src/VBox/Runtime/testcase/tstRTAvl.cpp
- Timestamp:
- Feb 12, 2022 1:58:36 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTAvl.cpp
r93709 r93711 1411 1411 } 1412 1412 1413 /* remove all in random order . */1413 /* remove all in random order, doing adjacent lookups while at it. */ 1414 1414 for (unsigned i = 0; i < cItems; i++) 1415 1415 { 1416 1416 uint32_t const idx = PickSetBitAndClearIt(pbmPresent, cItems); 1417 1417 RTGCPHYS const Key = idx * cbStep; 1418 1419 /* pre-removal lookup tests */ 1418 1420 MYTESTNODE *pNode = (MYTESTNODE *)(intptr_t)i; 1419 int rc = Tree.remove(&Allocator, idx * cbStep, &pNode); 1421 int rc = Tree.lookupMatchingOrSmaller(&Allocator, Key, &pNode); 1422 if (rc != VINF_SUCCESS) 1423 RTTestIFailed("pre-remove lookupMatchingOrSmaller failed: %Rrc, i=%#x, idx=%#x (%RGp ... %RGp)", 1424 rc, i, idx, Key, Key + cbStep - 1); 1425 else if (pNode->Key != Key) 1426 RTTestIFailed("pre-remove lookupMatchingOrSmaller returned the wrong node: Key=%RGp, expected %RGp", pNode->Key, Key); 1427 1428 pNode = (MYTESTNODE *)(intptr_t)i; 1429 rc = Tree.lookupMatchingOrLarger(&Allocator, Key, &pNode); 1430 if (rc != VINF_SUCCESS) 1431 RTTestIFailed("pre-remove lookupMatchingOrLarger failed: %Rrc, i=%#x, idx=%#x (%RGp ... %RGp)", 1432 rc, i, idx, Key, Key + cbStep - 1); 1433 else if (pNode->Key != Key) 1434 RTTestIFailed("pre-remove lookupMatchingOrLarger returned the wrong node: Key=%RGp, expected %RGp", pNode->Key, Key); 1435 1436 /* remove */ 1437 pNode = (MYTESTNODE *)(intptr_t)i; 1438 rc = Tree.remove(&Allocator, Key, &pNode); 1420 1439 if (rc != VINF_SUCCESS) 1421 1440 RTTestIFailed("random remove failed: %Rrc, i=%#x, idx=%#x (%RGp ... %RGp)", 1422 rc, i, idx, idx * cbStep, idx * cbStep+ cbStep - 1);1441 rc, i, idx, Key, Key + cbStep - 1); 1423 1442 else 1424 1443 { 1425 1444 cInserted--; 1426 if ( pNode->Key != idx * cbStep1427 || pNode->KeyLast != idx * cbStep+ cbStep - 1)1445 if ( pNode->Key != Key 1446 || pNode->KeyLast != Key + cbStep - 1) 1428 1447 RTTestIFailed("random remove returned wrong node: %RGp ... %RGp, expected %RGp ... %RGp (i=%#x, idx=%#x)", 1429 pNode->Key, pNode->KeyLast, idx * cbStep, idx * cbStep+ cbStep - 1, i, idx);1448 pNode->Key, pNode->KeyLast, Key, Key + cbStep - 1, i, idx); 1430 1449 else 1431 1450 { 1432 1451 MYTESTNODE *pNode2 = (MYTESTNODE *)(intptr_t)i; 1433 rc = Tree.lookup(&Allocator, idx * cbStep, &pNode2);1452 rc = Tree.lookup(&Allocator, Key, &pNode2); 1434 1453 if (rc != VERR_NOT_FOUND) 1435 1454 RTTestIFailed("lookup after random removal %#x: %Rrc pNode=%p pNode2=%p idx=%#x", i, rc, pNode, pNode2, idx); … … 1446 1465 if (rc != VINF_SUCCESS) 1447 1466 RTTestIFailed("free after random removal %#x failed: %Rrc pNode=%p idx=%#x", i, rc, pNode, idx); 1467 1468 /* post-removal lookup tests */ 1469 pNode = (MYTESTNODE *)(intptr_t)i; 1470 rc = Tree.lookupMatchingOrSmaller(&Allocator, Key, &pNode); 1471 uint32_t idxAbove; 1472 if (rc == VINF_SUCCESS) 1473 { 1474 uint32_t idxRet = pNode->Key / cbStep; 1475 RTTESTI_CHECK(ASMBitTest(pbmPresent, idxRet) == true); 1476 idxAbove = (uint32_t)ASMBitNextSet(pbmPresent, cItems, idxRet); 1477 if (idxAbove <= idx) 1478 RTTestIFailed("post-remove lookupMatchingOrSmaller wrong: idxRet=%#x idx=%#x idxAbove=%#x", 1479 idxRet, idx, idxAbove); 1480 } 1481 else if (rc == VERR_NOT_FOUND) 1482 { 1483 idxAbove = (uint32_t)ASMBitFirstSet(pbmPresent, cItems); 1484 if (idxAbove <= idx) 1485 RTTestIFailed("post-remove lookupMatchingOrSmaller wrong: VERR_NOT_FOUND idx=%#x idxAbove=%#x", idx, idxAbove); 1486 } 1487 else 1488 { 1489 RTTestIFailed("post-remove lookupMatchingOrSmaller failed: %Rrc, i=%#x, idx=%#x (%RGp ... %RGp)", 1490 rc, i, idx, Key, Key + cbStep - 1); 1491 idxAbove = (uint32_t)ASMBitNextSet(pbmPresent, cItems, idx); 1492 } 1493 1494 pNode = (MYTESTNODE *)(intptr_t)i; 1495 rc = Tree.lookupMatchingOrLarger(&Allocator, Key, &pNode); 1496 if (rc == VINF_SUCCESS) 1497 { 1498 uint32_t idxRet = pNode->Key / cbStep; 1499 if (idxRet != idxAbove) 1500 RTTestIFailed("post-remove lookupMatchingOrLarger wrong: idxRet=%#x idxAbove=%#x idx=%#x", 1501 idxRet, idxAbove, idx); 1502 } 1503 else if (rc == VERR_NOT_FOUND) 1504 { 1505 if (idxAbove != UINT32_MAX) 1506 RTTestIFailed("post-remove lookupMatchingOrLarger wrong: VERR_NOT_FOUND idxAbove=%#x idx=%#x", idxAbove, idx); 1507 } 1508 else 1509 { 1510 RTTestIFailed("post-remove lookupMatchingOrLarger failed: %Rrc, i=%#x, idx=%#x (%RGp ... %RGp) idxAbove=%#x", 1511 rc, i, idx, Key, Key + cbStep - 1, idxAbove); 1512 } 1448 1513 } 1449 1514
Note:
See TracChangeset
for help on using the changeset viewer.