Skip to content

Commit

Permalink
Fix "leaks" return status checking.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bzbarsky-apple committed Sep 25, 2024
1 parent 34c0fe1 commit 0551e38
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,28 @@ - (void)tearDown
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
Expand Down

0 comments on commit 0551e38

Please sign in to comment.