Control: tags -1 patch
Please find a patch attached that prevents the bad alloc.
The test will still fail though.
--- a/src/test/texecutor.cpp
+++ b/src/test/texecutor.cpp
@@ -398,13 +398,27 @@ void TestCommandFactory::testUndo() {
}
void TestCommandFactory::replayIsRobust() {
- loadOomTestUtil();
+ bool oomLoaded = loadOomTestUtil();
+ if (!oomLoaded) {
+ QSKIP("OOM test utility not loaded - skipping test");
+ }
+
+ // Ensure clean state before starting the test
+ cancelAnyMallocFailure();
+
+ // Test that setMallocsUntilFailure(0) makes the next malloc fail
setMallocsUntilFailure(0);
- QVERIFY2(0 == malloc(1), "SetMallocsUntilFailure(0) not working");
+ void* shouldFail1 = malloc(1);
+ cancelAnyMallocFailure();
+ QVERIFY2(shouldFail1 == 0, "SetMallocsUntilFailure(0) not working");
+
+ // Test that setMallocsUntilFailure(1) allows exactly one malloc then fails
setMallocsUntilFailure(1);
void* shouldSucceed = malloc(1);
- QVERIFY2(shouldSucceed,
+ void* shouldFail2 = malloc(1);
+ cancelAnyMallocFailure();
+ QVERIFY2(shouldSucceed != 0,
"SetMallocsUntilFailure not allowing mallocs at all");
free(shouldSucceed);
- QVERIFY2(0 == malloc(1), "SetMallocsUntilFailure(1) not working");
+ QVERIFY2(shouldFail2 == 0, "SetMallocsUntilFailure(1) not working");
}