aboutsummaryrefslogtreecommitdiffstats
path: root/gtest/test/gtest_break_on_failure_unittest_.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gtest/test/gtest_break_on_failure_unittest_.cc')
-rw-r--r--gtest/test/gtest_break_on_failure_unittest_.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/gtest/test/gtest_break_on_failure_unittest_.cc b/gtest/test/gtest_break_on_failure_unittest_.cc
index 10a1203..d28d1d3 100644
--- a/gtest/test/gtest_break_on_failure_unittest_.cc
+++ b/gtest/test/gtest_break_on_failure_unittest_.cc
@@ -43,6 +43,7 @@
#if GTEST_OS_WINDOWS
#include <windows.h>
+#include <stdlib.h>
#endif
namespace {
@@ -52,6 +53,14 @@ TEST(Foo, Bar) {
EXPECT_EQ(2, 3);
}
+#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
+// On Windows Mobile global exception handlers are not supported.
+LONG WINAPI ExitWithExceptionCode(
+ struct _EXCEPTION_POINTERS* exception_pointers) {
+ exit(exception_pointers->ExceptionRecord->ExceptionCode);
+}
+#endif
+
} // namespace
int main(int argc, char **argv) {
@@ -59,7 +68,18 @@ int main(int argc, char **argv) {
// Suppresses display of the Windows error dialog upon encountering
// a general protection fault (segment violation).
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
+
+#if !GTEST_OS_WINDOWS_MOBILE
+ // The default unhandled exception filter does not always exit
+ // with the exception code as exit code - for example it exits with
+ // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT
+ // if the application is compiled in debug mode. Thus we use our own
+ // filter which always exits with the exception code for unhandled
+ // exceptions.
+ SetUnhandledExceptionFilter(ExitWithExceptionCode);
+#endif
#endif
+
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();