Commit 1780d3ce authored by Michael Wasserman's avatar Michael Wasserman Committed by Commit Bot

Revert "[base] Cleanup StackTraceTest.OutputToStream #ifdef soup."

This reverts commit 2b5d8199.

Reason for revert: Causing consistent base_unittests StackTraceTest.OutputToStream failures on:
https://ci.chromium.org/p/chrome/builders/ci/chromeos-kevin-google-rel/3709

Original change's description:
> [base] Cleanup StackTraceTest.OutputToStream #ifdef soup.
> 
> Bug: 999737, 706728
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1780074
> Commit-Queue: Wez <wez@chromium.org>
> Reviewed-by: Albert J. Wong <ajwong@chromium.org>
> Auto-Submit: Wez <wez@chromium.org>
> Cr-Original-Commit-Position: refs/heads/master@{#712377}
> Change-Id: I627b5250055233ea89718a9143de356c85633add
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1905270
> Cr-Commit-Position: refs/heads/master@{#713876}

TBR=ajwong@chromium.org,wez@chromium.org

Change-Id: I2e09ac22e3c2fa66312d142664e7b03c1950989f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 999737, 706728
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1906545Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Commit-Queue: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713954}
parent 0d7346bd
...@@ -31,11 +31,25 @@ typedef MultiProcessTest StackTraceTest; ...@@ -31,11 +31,25 @@ typedef MultiProcessTest StackTraceTest;
typedef testing::Test StackTraceTest; typedef testing::Test StackTraceTest;
#endif #endif
#if !defined(__UCLIBC__) && !defined(_AIX) // TODO(https://crbug.com/999737): Rewrite this test for better clarity and
// StackTrace::OutputToStream() is not implemented under uclibc, nor AIX. // correctness.
// See https://crbug.com/706728 // Note: On Linux, this test currently only fully works on Debug builds.
// See comments in the #ifdef soup if you intend to change this.
#if defined(OS_WIN)
// Always fails on Windows: crbug.com/32070
#define MAYBE_OutputToStream DISABLED_OutputToStream
#elif defined(OS_FUCHSIA) && defined(OFFICIAL_BUILD)
TEST_F(StackTraceTest, OutputToStream) { // Backtraces aren't supported by Fuchsia release-optimized builds.
#define MAYBE_OutputToStream DISABLED_OutputToStream
#else
#define MAYBE_OutputToStream OutputToStream
#endif
#if !defined(__UCLIBC__) && !defined(_AIX)
TEST_F(StackTraceTest, MAYBE_OutputToStream) {
StackTrace trace; StackTrace trace;
// Dump the trace into a string. // Dump the trace into a string.
...@@ -46,54 +60,76 @@ TEST_F(StackTraceTest, OutputToStream) { ...@@ -46,54 +60,76 @@ TEST_F(StackTraceTest, OutputToStream) {
// ToString() should produce the same output. // ToString() should produce the same output.
EXPECT_EQ(backtrace_message, trace.ToString()); EXPECT_EQ(backtrace_message, trace.ToString());
size_t frames_found = 0; #if defined(OS_POSIX) && !defined(OS_MACOSX) && NDEBUG
const void* const* addresses = trace.Addresses(&frames_found);
ASSERT_TRUE(addresses);
ASSERT_GT(frames_found, 0u) << "No stack frames found.";
#if defined(OFFICIAL_BUILD) && defined(OS_POSIX) && !defined(OS_MACOSX)
// Stack traces require an extra data table that bloats our binaries, // Stack traces require an extra data table that bloats our binaries,
// so they're turned off for official builds. Stop the test here, so // so they're turned off for release builds. We stop the test here,
// it at least verifies that StackTrace calls don't crash. // at least letting us verify that the calls don't crash.
return;
#endif // defined(OFFICIAL_BUILD) && defined(OS_POSIX) && !defined(OS_MACOSX)
ASSERT_GT(frames_found, 5u) << "Too few frames found.";
#if defined(OS_FUCHSIA) || defined(OS_ANDROID)
// Under Fuchsia and Android, StackTrace emits executable build-Ids and
// address offsets which are symbolized on the test host system, rather than
// being symbolized in-process.
return; return;
#endif // defined(OS_FUCHSIA) || defined(OS_ANDROID) #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && NDEBUG
#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) size_t frames_found = 0;
// Configurations such as ASAN and TSan emit unsymbolized stacks. trace.Addresses(&frames_found);
return; ASSERT_GE(frames_found, 5u) <<
#endif // defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) "No stack frames found. Skipping rest of test.";
// Check if the output has symbol initialization warning. If it does, fail. // Check if the output has symbol initialization warning. If it does, fail.
ASSERT_EQ(backtrace_message.find("Dumping unresolved backtrace"), ASSERT_EQ(backtrace_message.find("Dumping unresolved backtrace"),
std::string::npos) std::string::npos) <<
<< "Unable to resolve symbols."; "Unable to resolve symbols. Skipping rest of test.";
#if defined(OS_MACOSX)
#if 0
// Disabled due to -fvisibility=hidden in build config.
// Symbol resolution via the backtrace_symbol function does not work well
// in OS X.
// See this thread:
//
// http://lists.apple.com/archives/darwin-dev/2009/Mar/msg00111.html
//
// Just check instead that we find our way back to the "start" symbol
// which should be the first symbol in the trace.
//
// TODO(port): Find a more reliable way to resolve symbols.
// Expect to at least find main.
EXPECT_TRUE(backtrace_message.find("start") != std::string::npos)
<< "Expected to find start in backtrace:\n"
<< backtrace_message;
#endif
#elif defined(USE_SYMBOLIZE)
// This branch is for gcc-compiled code, but not Mac due to the
// above #if.
// Expect a demangled symbol. // Expect a demangled symbol.
// Note that Windows Release builds omit the function parameters from the EXPECT_TRUE(backtrace_message.find("testing::Test::Run()") !=
// demangled stack output, otherwise this could be "testing::Test::Run()". std::string::npos)
EXPECT_TRUE(backtrace_message.find("testing::Test::Run") != std::string::npos)
<< "Expected a demangled symbol in backtrace:\n" << "Expected a demangled symbol in backtrace:\n"
<< backtrace_message; << backtrace_message;
#elif 0
// This is the fall-through case; it used to cover Windows.
// But it's disabled because of varying buildbot configs;
// some lack symbols.
// Expect to at least find main. // Expect to at least find main.
EXPECT_TRUE(backtrace_message.find("main") != std::string::npos) EXPECT_TRUE(backtrace_message.find("main") != std::string::npos)
<< "Expected to find main in backtrace:\n" << "Expected to find main in backtrace:\n"
<< backtrace_message; << backtrace_message;
#if defined(OS_WIN)
// MSVC doesn't allow the use of C99's __func__ within C++, so we fake it with
// MSVC's __FUNCTION__ macro.
#define __func__ __FUNCTION__
#endif
// Expect to find this function as well. // Expect to find this function as well.
// Note: This will fail if not linked with -rdynamic (aka -export_dynamic) // Note: This will fail if not linked with -rdynamic (aka -export_dynamic)
EXPECT_TRUE(backtrace_message.find(__func__) != std::string::npos) EXPECT_TRUE(backtrace_message.find(__func__) != std::string::npos)
<< "Expected to find " << __func__ << " in backtrace:\n" << "Expected to find " << __func__ << " in backtrace:\n"
<< backtrace_message; << backtrace_message;
#endif // define(OS_MACOSX)
} }
#if !defined(OFFICIAL_BUILD) && !defined(NO_UNWIND_TABLES) #if !defined(OFFICIAL_BUILD) && !defined(NO_UNWIND_TABLES)
...@@ -110,7 +146,7 @@ TEST_F(StackTraceTest, TruncatedTrace) { ...@@ -110,7 +146,7 @@ TEST_F(StackTraceTest, TruncatedTrace) {
truncated.Addresses(&count); truncated.Addresses(&count);
EXPECT_EQ(2u, count); EXPECT_EQ(2u, count);
} }
#endif // !defined(OFFICIAL_BUILD) && !defined(NO_UNWIND_TABLES) #endif // !defined(OFFICIAL_BUILD)
// The test is used for manual testing, e.g., to see the raw output. // The test is used for manual testing, e.g., to see the raw output.
TEST_F(StackTraceTest, DebugOutputToStream) { TEST_F(StackTraceTest, DebugOutputToStream) {
...@@ -158,7 +194,7 @@ TEST_F(StackTraceTest, DebugOutputToStreamWithNullPrefix) { ...@@ -158,7 +194,7 @@ TEST_F(StackTraceTest, DebugOutputToStreamWithNullPrefix) {
trace.ToStringWithPrefix(nullptr); trace.ToStringWithPrefix(nullptr);
} }
#endif // !defined(__UCLIBC__) && !defined(_AIX) #endif // !defined(__UCLIBC__)
#if defined(OS_POSIX) && !defined(OS_ANDROID) #if defined(OS_POSIX) && !defined(OS_ANDROID)
#if !defined(OS_IOS) #if !defined(OS_IOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment