Skip to content

Commit

Permalink
Work around random "leaks" failures in CI. (#35762)
Browse files Browse the repository at this point in the history
It seems that "leaks" randomly fails on the new (ARM) Darwin runners.  For now,
just ignore failures and only fail the test suite if "leaks" ran to completion
but detected leaks.
  • Loading branch information
bzbarsky-apple authored Sep 25, 2024
1 parent ed5c819 commit 34c0fe1
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,26 @@ - (void)setUp
- (void)tearDown
{
#if defined(ENABLE_LEAK_DETECTION) && ENABLE_LEAK_DETECTION
/**
* Unfortunately, doing this in "+ (void)tearDown" (the global suite teardown)
* does not trigger a test failure even if the XCTAssertEqual below fails.
*/
if (_detectLeaks) {
int pid = getpid();
__auto_type * cmd = [NSString stringWithFormat:@"leaks %d", pid];
int ret = system(cmd.UTF8String);
/**
* Unfortunately, doing this in "+ (void)tearDown" (the global suite teardown)
* does not trigger a test failure even if the XCTAssertEqual fails.
*/
XCTAssertEqual(ret, 0, "LEAKS DETECTED");
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.
// Just log and ignore for now.
XCTAssertFalse(WIFSTOPPED(ret), "Not expecting a stopped leaks");
NSLog(@"Stopped by signal %d", WTERMSIG(ret));
}
}
#endif

Expand Down

0 comments on commit 34c0fe1

Please sign in to comment.