Make breakpad_unittests work with Chrome's test runner instead of gtest's
Chrome's test runner on Linux installs its own StackDumpSignalHandler which swallows signals and doesn't re-raise them. This is sloppy, but apparently there are reasons (https://crbug.com/551681). For breakpad_unittests, it causes problems where a test process expects (via waitpid()) to observe a child crash. Deal with those cases by explicitly restoring the default signal handler. In another case, Chrome's test runner seems to have been arriving at the conclusion that it was to expect output from a child. Transitioning from exit() to _exit() fixes this problem, and it's not necessarily a bad idea to do this in post-fork() children without an execve() anyway. Bug: chromium:949098 Change-Id: I5a6af0c2a09cd8eac9998358f6d5ea665288236f Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1575670 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
ebab5970b0
commit
8c70c504b2
3 changed files with 13 additions and 3 deletions
|
@ -421,6 +421,10 @@ TEST(ExceptionHandlerTest, RedeliveryToDefaultHandler) {
|
||||||
|
|
||||||
const pid_t child = fork();
|
const pid_t child = fork();
|
||||||
if (child == 0) {
|
if (child == 0) {
|
||||||
|
// Custom signal handlers, which may have been installed by a test launcher,
|
||||||
|
// are undesirable in this child.
|
||||||
|
signal(SIGSEGV, SIG_DFL);
|
||||||
|
|
||||||
CrashWithCallbacks(FilterCallbackReturnFalse, NULL, temp_dir.path());
|
CrashWithCallbacks(FilterCallbackReturnFalse, NULL, temp_dir.path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ class LinuxPtraceDumperChildTest : public testing::Test {
|
||||||
if (child_pid_ == 0) {
|
if (child_pid_ == 0) {
|
||||||
// child process
|
// child process
|
||||||
RealTestBody();
|
RealTestBody();
|
||||||
exit(HasFatalFailure() ? kFatalFailure :
|
_exit(HasFatalFailure() ? kFatalFailure :
|
||||||
(HasNonfatalFailure() ? kNonFatalFailure : 0));
|
(HasNonfatalFailure() ? kNonFatalFailure : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ void LinuxPtraceDumperMappingsTest::SetUp() {
|
||||||
helper_path_ = GetHelperBinary();
|
helper_path_ = GetHelperBinary();
|
||||||
if (helper_path_.empty()) {
|
if (helper_path_.empty()) {
|
||||||
FAIL() << "Couldn't find helper binary";
|
FAIL() << "Couldn't find helper binary";
|
||||||
exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// mmap two segments out of the helper binary, one
|
// mmap two segments out of the helper binary, one
|
||||||
|
|
|
@ -184,6 +184,12 @@ bool CrashGenerator::CreateChildCrash(
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
|
// Custom signal handlers, which may have been installed by a test launcher,
|
||||||
|
// are undesirable in this child.
|
||||||
|
if (signal(crash_signal, SIG_DFL) == SIG_ERR) {
|
||||||
|
perror("CrashGenerator: signal");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
if (chdir(temp_dir_.path().c_str()) == -1) {
|
if (chdir(temp_dir_.path().c_str()) == -1) {
|
||||||
perror("CrashGenerator: Failed to change directory");
|
perror("CrashGenerator: Failed to change directory");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in a new issue