diff options
author | qsr@chromium.org <qsr@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-03-09 19:11:58 +0000 |
---|---|---|
committer | qsr@chromium.org <qsr@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2012-03-09 19:11:58 +0000 |
commit | b1f858f26b136044922eeae0d86488b17b54efff (patch) | |
tree | e805f24222008bd24199ca836915cc66587912f8 /src/client/mac/tests/exception_handler_test.cc | |
parent | Add COPYING file per libcurl distribution requirements (diff) | |
download | breakpad-b1f858f26b136044922eeae0d86488b17b54efff.tar.xz |
Add SIGABRT handler for mac and iOS.
SIGABRT were not handled while in process. This change add a signal handler to
handle this.
Review URL: https://breakpad.appspot.com/360001
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@933 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/mac/tests/exception_handler_test.cc')
-rw-r--r-- | src/client/mac/tests/exception_handler_test.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/client/mac/tests/exception_handler_test.cc b/src/client/mac/tests/exception_handler_test.cc index 02ff0f56..ee3ffa5b 100644 --- a/src/client/mac/tests/exception_handler_test.cc +++ b/src/client/mac/tests/exception_handler_test.cc @@ -64,6 +64,7 @@ using testing::Test; class ExceptionHandlerTest : public Test { public: + void InProcessCrash(bool aborting); AutoTempDir tempDir; string lastDumpName; }; @@ -75,8 +76,13 @@ static void Crasher() { fprintf(stdout, "A = %d", *a); } -static void SoonToCrash() { - Crasher(); +static void AbortCrasher() { + fprintf(stdout, "Going to crash...\n"); + abort(); +} + +static void SoonToCrash(void(*crasher)()) { + crasher(); } static bool MDCallback(const char *dump_dir, const char *file_name, @@ -94,7 +100,7 @@ static bool MDCallback(const char *dump_dir, const char *file_name, return true; } -TEST_F(ExceptionHandlerTest, InProcess) { +void ExceptionHandlerTest::InProcessCrash(bool aborting) { // Give the child process a pipe to report back on. int fds[2]; ASSERT_EQ(0, pipe(fds)); @@ -105,7 +111,7 @@ TEST_F(ExceptionHandlerTest, InProcess) { close(fds[0]); ExceptionHandler eh(tempDir.path(), NULL, MDCallback, &fds[1], true, NULL); // crash - SoonToCrash(); + SoonToCrash(aborting ? &AbortCrasher : &Crasher); // not reached exit(1); } @@ -128,6 +134,16 @@ TEST_F(ExceptionHandlerTest, InProcess) { EXPECT_EQ(0, WEXITSTATUS(ret)); } +TEST_F(ExceptionHandlerTest, InProcess) { + InProcessCrash(false); +} + +#if TARGET_OS_IPHONE +TEST_F(ExceptionHandlerTest, InProcessAbort) { + InProcessCrash(true); +} +#endif + static bool DumpNameMDCallback(const char *dump_dir, const char *file_name, void *context, bool success) { ExceptionHandlerTest *self = reinterpret_cast<ExceptionHandlerTest*>(context); |