Skip to content

Commit 34c0fe1

Browse files
Work around random "leaks" failures in CI. (project-chip#35762)
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 ed5c819 commit 34c0fe1

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)