[Testing] Make sure tests clean up shm resources on exit
This commit is contained in:
@@ -431,15 +431,20 @@ TestResult RunTestInChildProcess(TestSuite& test_suite, TestCase& test_case) {
|
|||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
// Child process - create a fresh TestRunner to avoid inherited state issues
|
// Child process - create a fresh TestRunner to avoid inherited state issues
|
||||||
TestRunner child_runner;
|
// Use a scope block to ensure destructors run before _exit(),
|
||||||
if (!child_runner.Setup(test_suite)) {
|
// otherwise shared memory objects in /dev/shm are never cleaned up.
|
||||||
_exit(2); // Setup failure
|
int exit_code;
|
||||||
}
|
{
|
||||||
if (child_runner.Run(test_case)) {
|
TestRunner child_runner;
|
||||||
_exit(0); // Test passed
|
if (!child_runner.Setup(test_suite)) {
|
||||||
} else {
|
exit_code = 2; // Setup failure
|
||||||
_exit(1); // Test failed
|
} else if (child_runner.Run(test_case)) {
|
||||||
}
|
exit_code = 0; // Test passed
|
||||||
|
} else {
|
||||||
|
exit_code = 1; // Test failed
|
||||||
|
}
|
||||||
|
} // child_runner destructor runs here, cleaning up shm
|
||||||
|
_exit(exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent process - wait for child
|
// Parent process - wait for child
|
||||||
|
|||||||
Reference in New Issue
Block a user