| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/debug/debugger.h" | 5 #include "base/debug/debugger.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | 12 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
| 13 void CrashWithBreakDebugger() { | 13 void CrashWithBreakDebugger() { |
| 14 base::debug::SetSuppressDebugUI(false); | 14 base::debug::SetSuppressDebugUI(false); |
| 15 base::debug::BreakDebugger(); | 15 base::debug::BreakDebugger(); |
| 16 | 16 |
| 17 #if defined(OS_WIN) | |
| 18 // This should not be executed. | |
| 19 _exit(125); | |
| 20 #endif | |
| 21 } | 17 } |
| 22 #endif // defined(GTEST_HAS_DEATH_TEST) | 18 #endif // defined(GTEST_HAS_DEATH_TEST) |
| 23 | 19 |
| 24 } // namespace | 20 } // namespace |
| 25 | 21 |
| 26 // Death tests misbehave on Android. | 22 // Death tests misbehave on Android. |
| 27 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | 23 #if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
| 28 | 24 |
| 29 TEST(Debugger, CrashAtBreakpoint) { | 25 TEST(Debugger, CrashAtBreakpoint) { |
| 30 EXPECT_DEATH(CrashWithBreakDebugger(), ""); | 26 EXPECT_DEATH(CrashWithBreakDebugger(), ""); |
| 31 } | 27 } |
| 32 | 28 |
| 33 #if defined(OS_WIN) | |
| 34 TEST(Debugger, DoesntExecuteBeyondBreakpoint) { | |
| 35 EXPECT_EXIT(CrashWithBreakDebugger(), | |
| 36 ::testing::ExitedWithCode(0x80000003), ""); | |
| 37 } | |
| 38 #endif // defined(OS_WIN) | |
| 39 | |
| 40 #else // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | 29 #else // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
| 41 TEST(Debugger, NoTest) { | 30 TEST(Debugger, NoTest) { |
| 42 } | 31 } |
| 43 #endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) | 32 #endif // defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID) |
| OLD | NEW |