Fix tests sometimes running multiple times due to some failing test 11/319311/1
authorKrzysztof Malysa <k.malysa@samsung.com>
Thu, 6 Feb 2025 13:40:46 +0000 (14:40 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Fri, 7 Feb 2025 07:30:42 +0000 (08:30 +0100)
Change-Id: I1d03d20fd633fd0c52920de6ef20a5424dcbd203

src/framework/src/test_runner.cpp

index 26a11d28a7f099641d9debabb13086ca5aaf5fc6..b1f18616413cd87b05a7ee02b28815e39e1c818d 100644 (file)
@@ -246,8 +246,15 @@ void TestRunner::RunTestCase(TestCasePtr testCase)
     SafeCleanup::reset();
 
     std::string testReason;
+    auto pid = getpid();
     TestResult::FailStatus testStatus = TryCatch(std::bind(&TestCase::Test, testCase),
                                                  testReason);
+    if (getpid() != pid) {
+        fprintf(stderr, "Child process did not die, exiting with 1. Reason: %s", testReason.c_str());
+        // Child process failed by throwing exception instead of dying, we need to exit - only the
+        // parent (original) process should proceed with running the tests.
+        _exit(1);
+    }
     testReason = getConcatedFailReason(testReason);
     std::string finishReason;
     TestResult::FailStatus finishStatus = TryCatch(std::bind(&TestCase::Finish, testCase),