Fix "leaks" return status checking. (#35769)

Looks like when "leaks" hits the CI failures it actually runs to completion but
returns an error status that is not 1, instead of being signaled.  Adjust the
workaround logic to account for this.
diff --git a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm
index ee03657..915df78 100644
--- a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm
+++ b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm
@@ -73,17 +73,28 @@
         int pid = getpid();
         __auto_type * cmd = [NSString stringWithFormat:@"leaks %d", pid];
         int ret = system(cmd.UTF8String);
-        if (WIFEXITED(ret)) {
-            // leaks ran to completion.
-            XCTAssertEqual(WEXITSTATUS(ret), 0, "LEAKS DETECTED");
-        } else {
-            // leaks failed to actually run to completion (e.g. crashed or ran
-            // into some other sort of failure trying to do its work).  Ideally
-            // we would fail our tests in that case, but this seems to be
-            // happening a fair amount, and randomly, on the ARM GitHub runners.
+        if (WIFSIGNALED(ret)) {
+            XCTFail(@"leaks unexpectedly stopped by signal %d", WTERMSIG(ret));
+        }
+        XCTAssertTrue(WIFEXITED(ret), "leaks did not run to completion");
+        // The exit status is 0 if no leaks detected, 1 if leaks were detected,
+        // something else on error.
+        if (WEXITSTATUS(ret) == 1) {
+            XCTFail(@"LEAKS DETECTED");
+        } else if (WEXITSTATUS(ret) != 0) {
+            // leaks failed to actually run correctly.  Ideally we would fail
+            // our tests in that case, but this seems to be happening a fair
+            // amount, and randomly, on the ARM GitHub runners, with errors
+            // like:
+            //
+            // *** getStackLoggingSharedMemoryAddressFromTask: couldn't find ___mach_stack_logging_shared_memory_address in target task
+            // *** task_malloc_get_all_zones: error 1 reading num_zones at 0
+            // *** task_malloc_get_all_zones: error 1 reading num_zones at 0
+            // *** task_malloc_get_all_zones: error 1 reading num_zones at 0
+            // [fatal] unable to instantiate a memory scanner.
+            //
             // Just log and ignore for now.
-            XCTAssertFalse(WIFSTOPPED(ret), "Not expecting a stopped leaks");
-            NSLog(@"Stopped by signal %d", WTERMSIG(ret));
+            NSLog(@"leaks failed to run, exit status: %d", WEXITSTATUS(ret));
         }
     }
 #endif