From b27f43f1edc71253e7f26cd37d6da71dec543fbf Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Thu, 18 Jan 2024 17:44:09 -0800 Subject: [PATCH] Propagate error code in test --- ConflictSet.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index d01b706..f1462e4 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -540,6 +540,7 @@ void checkParentPointers(Node *node, bool &success) { fprintf(stderr, "%.*s child %d has parent pointer %p. Expected %p\n", node->len, (const char *)(node + 1), i, (void *)node->child[i]->parent, (void *)node); + success = false; } checkParentPointers(node->child[i], success); } @@ -556,8 +557,8 @@ int64_t checkMaxVersion(Node *node, bool &success) { if (node->maxVersion != expected) { fprintf(stderr, "%.*s has max version %d. Expected %d\n", node->len, (const char *)(node + 1), int(node->maxVersion), int(expected)); + success = false; } - success = false; return expected; } @@ -623,8 +624,8 @@ struct ConflictSet::Impl { } struct StepwiseInsert { - // Search phase state. After this phase, the heap invariant may be violated - // for (*current)->parent. + // After this phase, the heap invariant may be violated for + // (*current)->parent. Node **current; Node *parent; const Key *key; @@ -643,7 +644,7 @@ struct ConflictSet::Impl { if (*current == nullptr) { auto *newNode = createNode(*key, parent, writeVersion); *current = newNode; - // We could interleave the iteration in next, but we'd need a careful + // We could interleave the iteration in ::next, but we'd need a careful // analysis for correctness and it's unlikely to be worthwhile. auto *prev = ::next(newNode, false); assert(prev != nullptr); @@ -797,6 +798,7 @@ int main(void) { } cs.addWrites(write, kNumKeys); debugPrintDot(stdout, cs.root); - checkInvariants(cs.root); + bool success = checkInvariants(cs.root); + return success ? 0 : 1; } #endif \ No newline at end of file