aboutsummaryrefslogtreecommitdiff
path: root/src/client/mac/tests/exception_handler_test.cc
diff options
context:
space:
mode:
authorted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-12-15 16:28:28 +0000
committerted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-12-15 16:28:28 +0000
commit0d9bd40775211c223c75543890d862135f677d67 (patch)
treeb5124e137fe2d99b7551d4b5d70f5d17cf8b130d /src/client/mac/tests/exception_handler_test.cc
parentissue 334 - Fix a race condition between ExceptionHandler::Teardown and Excep... (diff)
downloadbreakpad-0d9bd40775211c223c75543890d862135f677d67.tar.xz
Allow writing on-request minidumps with an exception stream
R=mark at http://breakpad.appspot.com/172001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@745 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.cc47
1 files changed, 44 insertions, 3 deletions
diff --git a/src/client/mac/tests/exception_handler_test.cc b/src/client/mac/tests/exception_handler_test.cc
index ae2e0513..b1b74ef1 100644
--- a/src/client/mac/tests/exception_handler_test.cc
+++ b/src/client/mac/tests/exception_handler_test.cc
@@ -128,8 +128,8 @@ TEST_F(ExceptionHandlerTest, InProcess) {
EXPECT_EQ(0, WEXITSTATUS(ret));
}
-static bool ChildMDCallback(const char *dump_dir, const char *file_name,
- void *context, bool success) {
+static bool DumpNameMDCallback(const char *dump_dir, const char *file_name,
+ void *context, bool success) {
ExceptionHandlerTest *self = reinterpret_cast<ExceptionHandlerTest*>(context);
if (dump_dir && file_name) {
self->lastDumpName = dump_dir;
@@ -140,6 +140,47 @@ static bool ChildMDCallback(const char *dump_dir, const char *file_name,
return true;
}
+TEST_F(ExceptionHandlerTest, WriteMinidump) {
+ ExceptionHandler eh(tempDir.path, NULL, DumpNameMDCallback, this, true, NULL);
+ ASSERT_TRUE(eh.WriteMinidump());
+
+ // Ensure that minidump file exists and is > 0 bytes.
+ ASSERT_FALSE(lastDumpName.empty());
+ struct stat st;
+ ASSERT_EQ(0, stat(lastDumpName.c_str(), &st));
+ ASSERT_LT(0, st.st_size);
+
+ // The minidump should not contain an exception stream.
+ Minidump minidump(lastDumpName);
+ ASSERT_TRUE(minidump.Read());
+
+ MinidumpException* exception = minidump.GetException();
+ EXPECT_FALSE(exception);
+}
+
+TEST_F(ExceptionHandlerTest, WriteMinidumpWithException) {
+ ExceptionHandler eh(tempDir.path, NULL, DumpNameMDCallback, this, true, NULL);
+ ASSERT_TRUE(eh.WriteMinidump(true));
+
+ // Ensure that minidump file exists and is > 0 bytes.
+ ASSERT_FALSE(lastDumpName.empty());
+ struct stat st;
+ ASSERT_EQ(0, stat(lastDumpName.c_str(), &st));
+ ASSERT_LT(0, st.st_size);
+
+ // The minidump should contain an exception stream.
+ Minidump minidump(lastDumpName);
+ ASSERT_TRUE(minidump.Read());
+
+ MinidumpException* exception = minidump.GetException();
+ ASSERT_TRUE(exception);
+ const MDRawExceptionStream* raw_exception = exception->exception();
+ ASSERT_TRUE(raw_exception);
+
+ EXPECT_EQ(MD_EXCEPTION_MAC_BREAKPOINT,
+ raw_exception->exception_record.exception_code);
+}
+
TEST_F(ExceptionHandlerTest, DumpChildProcess) {
const int kTimeoutMs = 2000;
// Create a mach port to receive the child task on.
@@ -188,7 +229,7 @@ TEST_F(ExceptionHandlerTest, DumpChildProcess) {
bool result = ExceptionHandler::WriteMinidumpForChild(child_task,
child_thread,
tempDir.path,
- ChildMDCallback,
+ DumpNameMDCallback,
this);
ASSERT_EQ(true, result);