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:
parent
4febb34583
commit
e059dad5ea
1 changed files with 16 additions and 2 deletions
|
@ -305,8 +305,22 @@ TEST(ExceptionHandlerTest, ParallelChildCrashesDontHang) {
|
|||
}
|
||||
}
|
||||
|
||||
// Wait a while until the child should have crashed.
|
||||
usleep(1000000);
|
||||
// Poll the child to see if it crashed.
|
||||
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(child, SIGKILL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue