| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <sstream> | 5 #include <sstream> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 namespace debug { | 13 namespace debug { |
| 14 | 14 |
| 15 // Note: On Linux, this test currently only fully works on Debug builds. | 15 // Note: On Linux, this test currently only fully works on Debug builds. |
| 16 // See comments in the #ifdef soup if you intend to change this. | 16 // See comments in the #ifdef soup if you intend to change this. |
| 17 // Flaky, crbug.com/32070. | 17 #if defined(OS_WIN) |
| 18 TEST(StackTrace, FLAKY_OutputToStream) { | 18 // Always fails on Windows: crbug.com/32070 |
| 19 #define MAYBE_OutputToStream FAILS_OutputToStream |
| 20 #else |
| 21 #define MAYBE_OutputToStream OutputToStream |
| 22 #endif |
| 23 TEST(StackTrace, MAYBE_OutputToStream) { |
| 19 StackTrace trace; | 24 StackTrace trace; |
| 20 | 25 |
| 21 // Dump the trace into a string. | 26 // Dump the trace into a string. |
| 22 std::ostringstream os; | 27 std::ostringstream os; |
| 23 trace.OutputToStream(&os); | 28 trace.OutputToStream(&os); |
| 24 std::string backtrace_message = os.str(); | 29 std::string backtrace_message = os.str(); |
| 25 | 30 |
| 26 #if defined(OS_POSIX) && !defined(OS_MACOSX) && NDEBUG | 31 #if defined(OS_POSIX) && !defined(OS_MACOSX) && NDEBUG |
| 27 // Stack traces require an extra data table that bloats our binaries, | 32 // Stack traces require an extra data table that bloats our binaries, |
| 28 // so they're turned off for release builds. We stop the test here, | 33 // so they're turned off for release builds. We stop the test here, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 VLOG(1) << os.str(); | 108 VLOG(1) << os.str(); |
| 104 } | 109 } |
| 105 | 110 |
| 106 // The test is used for manual testing, e.g., to see the raw output. | 111 // The test is used for manual testing, e.g., to see the raw output. |
| 107 TEST(StackTrace, DebugPrintBacktrace) { | 112 TEST(StackTrace, DebugPrintBacktrace) { |
| 108 StackTrace().PrintBacktrace(); | 113 StackTrace().PrintBacktrace(); |
| 109 } | 114 } |
| 110 | 115 |
| 111 } // namespace debug | 116 } // namespace debug |
| 112 } // namespace base | 117 } // namespace base |
| OLD | NEW |