Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around random "leaks" failures in CI. #35762

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading