Skip to content

Commit 4a7350a

Browse files
committedSep 24, 2024
Work around random "leaks" failures in CI.
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.
1 parent e527611 commit 4a7350a

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed
 

‎src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm

+16-5
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,26 @@ - (void)setUp
6565
- (void)tearDown
6666
{
6767
#if defined(ENABLE_LEAK_DETECTION) && ENABLE_LEAK_DETECTION
68+
/**
69+
* Unfortunately, doing this in "+ (void)tearDown" (the global suite teardown)
70+
* does not trigger a test failure even if the XCTAssertEqual below fails.
71+
*/
6872
if (_detectLeaks) {
6973
int pid = getpid();
7074
__auto_type * cmd = [NSString stringWithFormat:@"leaks %d", pid];
7175
int ret = system(cmd.UTF8String);
72-
/**
73-
* Unfortunately, doing this in "+ (void)tearDown" (the global suite teardown)
74-
* does not trigger a test failure even if the XCTAssertEqual fails.
75-
*/
76-
XCTAssertEqual(ret, 0, "LEAKS DETECTED");
76+
if (WIFEXITED(ret)) {
77+
// leaks ran to completion.
78+
XCTAssertEqual(WEXITSTATUS(ret), 0, "LEAKS DETECTED");
79+
} else {
80+
// leaks failed to actually run to completion (e.g. crashed or ran
81+
// into some other sort of failure trying to do its work). Ideally
82+
// we would fail our tests in that case, but this seems to be
83+
// happening a fair amount, and randomly, on the ARM GitHub runners.
84+
// Just log and ignore for now.
85+
XCTAssertFalse(WIFSTOPPED(ret), "Not expecting a stopped leaks");
86+
NSLog(@"Stopped by signal %d", WTERMSIG(ret));
87+
}
7788
}
7889
#endif
7990

0 commit comments

Comments
 (0)