From 94b1c57d934d805f6b690644303afa48a856b3ab Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Tue, 15 Dec 2020 06:38:55 -0800 Subject: [PATCH] init: don't generate tombstones for expected test failures The firmware_handler.HandleAbort and subcontext.RecoverAfterAbort tests intentionally abort in the child process to ensure that ueventd/init can recover if their child processes die. This generates a tombstone which causes confusion. This change resets SIGABRT to SIG_DFL right before the abort(), so that the child processes will exit normally without generating a tombstone or writing a crash to logcat. Bug: 169771958 Bug: 175383788 Test: run the above tests and verify no stack traces are printed to logcat and no tombstones are generated. Change-Id: Ica09548d1c7a766bf5d9ff2e26c9fd558e85c7c1 --- init/firmware_handler_test.cpp | 2 ++ init/subcontext_test.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/init/firmware_handler_test.cpp b/init/firmware_handler_test.cpp index 7bb603c5d..5124a6f41 100644 --- a/init/firmware_handler_test.cpp +++ b/init/firmware_handler_test.cpp @@ -79,6 +79,8 @@ TEST(firmware_handler, HandleAbort) { } int HandleAbort(int argc, char** argv) { + // Since this is an expected failure, disable debuggerd to not generate a tombstone. + signal(SIGABRT, SIG_DFL); abort(); return 0; } diff --git a/init/subcontext_test.cpp b/init/subcontext_test.cpp index ee765a7a7..da1f45550 100644 --- a/init/subcontext_test.cpp +++ b/init/subcontext_test.cpp @@ -202,6 +202,8 @@ BuiltinFunctionMap BuildTestFunctionMap() { // For RecoverAfterAbort auto do_cause_log_fatal = [](const BuiltinArguments& args) -> Result { + // Since this is an expected failure, disable debuggerd to not generate a tombstone. + signal(SIGABRT, SIG_DFL); return Error() << std::string(4097, 'f'); }; auto do_generate_sane_error = [](const BuiltinArguments& args) -> Result {