Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: src/client/windows/unittests/exception_handler_death_test.cc

Issue 2050013: Added a death test for the pure virtual function call.... (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/client/windows/unittests/exception_handler_death_test.cc
===================================================================
--- src/client/windows/unittests/exception_handler_death_test.cc (revision 596)
+++ src/client/windows/unittests/exception_handler_death_test.cc (working copy)
@@ -53,7 +53,8 @@
// 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 @@
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 @@
// 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 @@
// 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();
Sigurður Ásgeirsson 2010/05/13 20:57:10 Really? How weird.
+ }
+ 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), "");
+}
+}
« no previous file with comments | « src/client/windows/handler/exception_handler.cc ('k') | src/client/windows/unittests/exception_handler_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698