From 435ea98a5a489039f9ee9dd7ae863bd542a092b7 Mon Sep 17 00:00:00 2001 From: "Herman S." <429230+has207@users.noreply.github.com> Date: Tue, 25 Nov 2025 13:17:30 +0900 Subject: [PATCH] [Testing] Make sure tests clean up shm resources on exit --- src/xenia/cpu/ppc/testing/ppc_testing_main.cc | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/xenia/cpu/ppc/testing/ppc_testing_main.cc b/src/xenia/cpu/ppc/testing/ppc_testing_main.cc index 26280403a..d25a7525e 100644 --- a/src/xenia/cpu/ppc/testing/ppc_testing_main.cc +++ b/src/xenia/cpu/ppc/testing/ppc_testing_main.cc @@ -431,15 +431,20 @@ TestResult RunTestInChildProcess(TestSuite& test_suite, TestCase& test_case) { if (pid == 0) { // Child process - create a fresh TestRunner to avoid inherited state issues - TestRunner child_runner; - if (!child_runner.Setup(test_suite)) { - _exit(2); // Setup failure - } - if (child_runner.Run(test_case)) { - _exit(0); // Test passed - } else { - _exit(1); // Test failed - } + // Use a scope block to ensure destructors run before _exit(), + // otherwise shared memory objects in /dev/shm are never cleaned up. + int exit_code; + { + TestRunner child_runner; + if (!child_runner.Setup(test_suite)) { + exit_code = 2; // Setup failure + } 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