aboutsummaryrefslogtreecommitdiff
path: root/src/client/windows/unittests/exception_handler_death_test.cc
diff options
context:
space:
mode:
authorhansl@google.com <hansl@google.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-13 21:00:43 +0000
committerhansl@google.com <hansl@google.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-13 21:00:43 +0000
commitbcf885c8079b1742bfd93de722afceb26237ce4f (patch)
treefe9e624dfbc969e41f8008f4dddd2a7aabe7750a /src/client/windows/unittests/exception_handler_death_test.cc
parentMoved exception_handler_test to the more aptly named exception_handler_death_... (diff)
downloadbreakpad-bcf885c8079b1742bfd93de722afceb26237ce4f.tar.xz
Added a death test for the pure virtual function call.
Added a test for the minidump generated by a pure virtual function call. Changed the pure virtual function call handler so that it creates a minidump with Exception info and a stack. Review URL: http://codereview.chromium.org/2050013 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@597 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/windows/unittests/exception_handler_death_test.cc')
-rwxr-xr-xsrc/client/windows/unittests/exception_handler_death_test.cc40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/client/windows/unittests/exception_handler_death_test.cc b/src/client/windows/unittests/exception_handler_death_test.cc
index a03ad011..36131403 100755
--- a/src/client/windows/unittests/exception_handler_death_test.cc
+++ b/src/client/windows/unittests/exception_handler_death_test.cc
@@ -53,7 +53,8 @@ class ExceptionHandlerDeathTest : public ::testing::Test {
// Actually constructs a temp path name.
virtual void SetUp();
// A helper method that tests can use to crash.
- void DoCrash();
+ void DoCrashAccessViolation();
+ void DoCrashPureVirtualCall();
};
void ExceptionHandlerDeathTest::SetUp() {
@@ -126,7 +127,7 @@ void clientDumpCallback(void *dump_context,
gDumpCallbackCalled = true;
}
-void ExceptionHandlerDeathTest::DoCrash() {
+void ExceptionHandlerDeathTest::DoCrashAccessViolation() {
google_breakpad::ExceptionHandler *exc =
new google_breakpad::ExceptionHandler(
temp_path_, NULL, NULL, NULL,
@@ -160,7 +161,7 @@ TEST_F(ExceptionHandlerDeathTest, OutOfProcTest) {
// being the same.
EXPECT_TRUE(server.Start());
EXPECT_FALSE(gDumpCallbackCalled);
- ASSERT_DEATH(this->DoCrash(), "");
+ ASSERT_DEATH(this->DoCrashAccessViolation(), "");
EXPECT_TRUE(gDumpCallbackCalled);
}
@@ -178,4 +179,37 @@ TEST_F(ExceptionHandlerDeathTest, InvalidParameterTest) {
// and a dump will be generated, the process will exit(0).
ASSERT_EXIT(printf(NULL), ::testing::ExitedWithCode(0), "");
}
+
+
+struct PureVirtualCallBase {
+ PureVirtualCallBase() {
+ // We have to reinterpret so the linker doesn't get confused because the
+ // method isn't defined.
+ reinterpret_cast<PureVirtualCallBase*>(this)->PureFunction();
+ }
+ virtual ~PureVirtualCallBase() {}
+ virtual void PureFunction() const = 0;
+};
+struct PureVirtualCall : public PureVirtualCallBase {
+ PureVirtualCall() { PureFunction(); }
+ virtual void PureFunction() const {}
+};
+
+void ExceptionHandlerDeathTest::DoCrashPureVirtualCall() {
+ PureVirtualCall instance;
+}
+
+TEST_F(ExceptionHandlerDeathTest, PureVirtualCallTest) {
+ using google_breakpad::ExceptionHandler;
+
+ ASSERT_TRUE(DoesPathExist(temp_path_));
+ ExceptionHandler handler(temp_path_, NULL, NULL, NULL,
+ ExceptionHandler::HANDLER_PURECALL);
+
+ // Disable the message box for assertions
+ _CrtSetReportMode(_CRT_ASSERT, 0);
+
+ // Calls a pure virtual function.
+ EXPECT_EXIT(DoCrashPureVirtualCall(), ::testing::ExitedWithCode(0), "");
+}
}