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

Side by Side Diff: base/debug/stack_trace_unittest.cc

Issue 2632643004: Remove WTFReportAssertionFailure and WTFReportBacktrace. (Closed)
Patch Set: Add Truncate() helper Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <limits> 7 #include <limits>
8 #include <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 // Expect to find this function as well. 116 // Expect to find this function as well.
117 // Note: This will fail if not linked with -rdynamic (aka -export_dynamic) 117 // Note: This will fail if not linked with -rdynamic (aka -export_dynamic)
118 EXPECT_TRUE(backtrace_message.find(__func__) != std::string::npos) 118 EXPECT_TRUE(backtrace_message.find(__func__) != std::string::npos)
119 << "Expected to find " << __func__ << " in backtrace:\n" 119 << "Expected to find " << __func__ << " in backtrace:\n"
120 << backtrace_message; 120 << backtrace_message;
121 121
122 #endif // define(OS_MACOSX) 122 #endif // define(OS_MACOSX)
123 } 123 }
124 124
125 TEST_F(StackTraceTest, TruncateTrace) {
126 StackTrace trace;
127
128 size_t count = 0;
129 const void* const* trace_ptrs = trace.Addresses(&count);
130 ASSERT_LT(2u, count);
131
132 StackTrace truncated = trace.Truncate(2);
133 const void* const* truncated_ptrs = truncated.Addresses(&count);
134 EXPECT_EQ(2u, count);
135
136 EXPECT_EQ(trace_ptrs[0], truncated_ptrs[0]);
137 EXPECT_EQ(trace_ptrs[1], truncated_ptrs[1]);
138 }
139
125 // The test is used for manual testing, e.g., to see the raw output. 140 // The test is used for manual testing, e.g., to see the raw output.
126 TEST_F(StackTraceTest, DebugOutputToStream) { 141 TEST_F(StackTraceTest, DebugOutputToStream) {
127 StackTrace trace; 142 StackTrace trace;
128 std::ostringstream os; 143 std::ostringstream os;
129 trace.OutputToStream(&os); 144 trace.OutputToStream(&os);
130 VLOG(1) << os.str(); 145 VLOG(1) << os.str();
131 } 146 }
132 147
133 // The test is used for manual testing, e.g., to see the raw output. 148 // The test is used for manual testing, e.g., to see the raw output.
134 TEST_F(StackTraceTest, DebugPrintBacktrace) { 149 TEST_F(StackTraceTest, DebugPrintBacktrace) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 TEST_F(StackTraceTest, MAYBE_TraceStackFramePointers) { 299 TEST_F(StackTraceTest, MAYBE_TraceStackFramePointers) {
285 constexpr size_t kDepth = 5; 300 constexpr size_t kDepth = 5;
286 const void* frames[kDepth]; 301 const void* frames[kDepth];
287 ExpectStackFramePointers<kDepth>(frames, kDepth); 302 ExpectStackFramePointers<kDepth>(frames, kDepth);
288 } 303 }
289 304
290 #endif // HAVE_TRACE_STACK_FRAME_POINTERS 305 #endif // HAVE_TRACE_STACK_FRAME_POINTERS
291 306
292 } // namespace debug 307 } // namespace debug
293 } // namespace base 308 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698