Polling in ParallelChildCrashesDontHang test

Instead of (arbitrarily) wait 1s for the child process to terminate, the
parent now polls the child process every 100ms to check if it's
terminated, and it does so for a much longer total time of 10s.

This implementation ensures correct check for slower architectures, and
fast success for faster ones.

Change-Id: I2ff38458bf747de5b74268a4e22fd6164450419b
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3876346
Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
Iacopo Colonnelli 2022-09-08 09:38:48 +02:00 committed by Mike Frysinger
parent 4febb34583
commit e059dad5ea

View file

@ -305,8 +305,22 @@ TEST(ExceptionHandlerTest, ParallelChildCrashesDontHang) {
} }
} }
// Wait a while until the child should have crashed. // Poll the child to see if it crashed.
usleep(1000000); int status, wp_pid;
for (int i = 0; i < 100; i++) {
wp_pid = HANDLE_EINTR(waitpid(child, &status, WNOHANG));
ASSERT_NE(-1, wp_pid);
if (wp_pid > 0) {
ASSERT_TRUE(WIFSIGNALED(status));
// If the child process terminated by itself,
// it will have returned SIGSEGV.
ASSERT_EQ(SIGSEGV, WTERMSIG(status));
return;
} else {
usleep(100000);
}
}
// Kill the child if it is still running. // Kill the child if it is still running.
kill(child, SIGKILL); kill(child, SIGKILL);