Check that all children have reachable present entries

This commit is contained in:
2024-02-05 16:59:21 -08:00
parent d78afe0823
commit 0aa2f67f88

View File

@@ -1173,11 +1173,28 @@ void checkParentPointers(Node *node, bool &success) {
return expected;
}
[[maybe_unused]] int64_t checkEntriesExist(Node *node, bool &success) {
int64_t total = node->entryPresent;
for (int i = getChildGeq(node, 0); i >= 0; i = getChildGeq(node, i + 1)) {
auto *child = getChildExists(node, i);
int64_t e = checkEntriesExist(child, success);
total += e;
if (e == 0) {
Arena arena;
fprintf(stderr, "%s has child %02x with no reachable entries\n",
printable(getSearchPath(arena, node)).c_str(), i);
success = false;
}
}
return total;
}
bool checkCorrectness(Node *node, ReferenceImpl &refImpl) {
bool success = true;
checkParentPointers(node, success);
checkMaxVersion(node, success);
checkEntriesExist(node, success);
std::string logicalMap;
std::string referenceLogicalMap;