| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <limits> | 5 #include <limits> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace debug { | 22 namespace debug { |
| 23 | 23 |
| 24 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_IOS) | 24 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_IOS) |
| 25 typedef MultiProcessTest StackTraceTest; | 25 typedef MultiProcessTest StackTraceTest; |
| 26 #else | 26 #else |
| 27 typedef testing::Test StackTraceTest; | 27 typedef testing::Test StackTraceTest; |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 // Note: On Linux, this test currently only fully works on Debug builds. | 30 // Note: On Linux, this test currently only fully works on Debug builds. |
| 31 // See comments in the #ifdef soup if you intend to change this. | 31 // See comments in the #ifdef soup if you intend to change this. |
| 32 #if defined(OS_WIN) | |
| 33 // Always fails on Windows: crbug.com/32070 | |
| 34 #define MAYBE_OutputToStream DISABLED_OutputToStream | |
| 35 #else | |
| 36 #define MAYBE_OutputToStream OutputToStream | 32 #define MAYBE_OutputToStream OutputToStream |
| 37 #endif | |
| 38 #if !defined(__UCLIBC__) | 33 #if !defined(__UCLIBC__) |
| 39 TEST_F(StackTraceTest, MAYBE_OutputToStream) { | 34 TEST_F(StackTraceTest, MAYBE_OutputToStream) { |
| 40 StackTrace trace; | 35 StackTrace trace; |
| 41 | 36 |
| 42 // Dump the trace into a string. | 37 // Dump the trace into a string. |
| 43 std::ostringstream os; | 38 std::ostringstream os; |
| 44 trace.OutputToStream(&os); | 39 trace.OutputToStream(&os); |
| 45 std::string backtrace_message = os.str(); | 40 std::string backtrace_message = os.str(); |
| 46 | 41 |
| 47 // ToString() should produce the same output. | 42 // ToString() should produce the same output. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 #elif 0 | 92 #elif 0 |
| 98 // This is the fall-through case; it used to cover Windows. | 93 // This is the fall-through case; it used to cover Windows. |
| 99 // But it's disabled because of varying buildbot configs; | 94 // But it's disabled because of varying buildbot configs; |
| 100 // some lack symbols. | 95 // some lack symbols. |
| 101 | 96 |
| 102 // Expect to at least find main. | 97 // Expect to at least find main. |
| 103 EXPECT_TRUE(backtrace_message.find("main") != std::string::npos) | 98 EXPECT_TRUE(backtrace_message.find("main") != std::string::npos) |
| 104 << "Expected to find main in backtrace:\n" | 99 << "Expected to find main in backtrace:\n" |
| 105 << backtrace_message; | 100 << backtrace_message; |
| 106 | 101 |
| 107 #if defined(OS_WIN) | |
| 108 // MSVC doesn't allow the use of C99's __func__ within C++, so we fake it with | |
| 109 // MSVC's __FUNCTION__ macro. | |
| 110 #define __func__ __FUNCTION__ | |
| 111 #endif | |
| 112 | |
| 113 // Expect to find this function as well. | 102 // Expect to find this function as well. |
| 114 // Note: This will fail if not linked with -rdynamic (aka -export_dynamic) | 103 // Note: This will fail if not linked with -rdynamic (aka -export_dynamic) |
| 115 EXPECT_TRUE(backtrace_message.find(__func__) != std::string::npos) | 104 EXPECT_TRUE(backtrace_message.find(__func__) != std::string::npos) |
| 116 << "Expected to find " << __func__ << " in backtrace:\n" | 105 << "Expected to find " << __func__ << " in backtrace:\n" |
| 117 << backtrace_message; | 106 << backtrace_message; |
| 118 | 107 |
| 119 #endif // define(OS_MACOSX) | 108 #endif // define(OS_MACOSX) |
| 120 } | 109 } |
| 121 | 110 |
| 122 // 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. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 1)); | 219 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 1)); |
| 231 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 2)); | 220 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 2)); |
| 232 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 3)); | 221 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 3)); |
| 233 EXPECT_EQ("0688", itoa_r_wrapper(0x688, 128, 16, 4)); | 222 EXPECT_EQ("0688", itoa_r_wrapper(0x688, 128, 16, 4)); |
| 234 EXPECT_EQ("00688", itoa_r_wrapper(0x688, 128, 16, 5)); | 223 EXPECT_EQ("00688", itoa_r_wrapper(0x688, 128, 16, 5)); |
| 235 } | 224 } |
| 236 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) | 225 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) |
| 237 | 226 |
| 238 } // namespace debug | 227 } // namespace debug |
| 239 } // namespace base | 228 } // namespace base |
| OLD | NEW |