summaryrefslogtreecommitdiff
path: root/chromium/base/logging_unittest.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 15:05:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-14 10:33:47 +0000
commite684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch)
treed55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/base/logging_unittest.cc
parent2b94bfe47ccb6c08047959d1c26e392919550e86 (diff)
downloadqtwebengine-chromium-e684a3455bcc29a6e3e66a004e352dea4e1141e7.tar.gz
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922 Reviewed-by: Michael Brüning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/base/logging_unittest.cc')
-rw-r--r--chromium/base/logging_unittest.cc69
1 files changed, 63 insertions, 6 deletions
diff --git a/chromium/base/logging_unittest.cc b/chromium/base/logging_unittest.cc
index 7ee632af6b2..366ba791bde 100644
--- a/chromium/base/logging_unittest.cc
+++ b/chromium/base/logging_unittest.cc
@@ -540,7 +540,7 @@ void DcheckEmptyFunction1() {
}
void DcheckEmptyFunction2() {}
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DCHECK_IS_CONFIGURABLE)
class ScopedDcheckSeverity {
public:
ScopedDcheckSeverity(LogSeverity new_severity) : old_severity_(LOG_DCHECK) {
@@ -552,7 +552,7 @@ class ScopedDcheckSeverity {
private:
LogSeverity old_severity_;
};
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DCHECK_IS_CONFIGURABLE)
// https://crbug.com/709067 tracks test flakiness on iOS.
#if defined(OS_IOS)
@@ -561,12 +561,12 @@ class ScopedDcheckSeverity {
#define MAYBE_Dcheck Dcheck
#endif
TEST_F(LoggingTest, MAYBE_Dcheck) {
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DCHECK_IS_CONFIGURABLE)
// DCHECKs are enabled, and LOG_DCHECK is mutable, but defaults to non-fatal.
// Set it to LOG_FATAL to get the expected behavior from the rest of this
// test.
ScopedDcheckSeverity dcheck_severity(LOG_FATAL);
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DCHECK_IS_CONFIGURABLE)
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
// Release build.
@@ -727,7 +727,7 @@ namespace nested_test {
}
} // namespace nested_test
-#if DCHECK_IS_CONFIGURABLE
+#if defined(DCHECK_IS_CONFIGURABLE)
TEST_F(LoggingTest, ConfigurableDCheck) {
// Verify that DCHECKs default to non-fatal in configurable-DCHECK builds.
// Note that we require only that DCHECK is non-fatal by default, rather
@@ -777,7 +777,7 @@ TEST_F(LoggingTest, ConfigurableDCheckFeature) {
EXPECT_LT(LOG_DCHECK, LOG_FATAL);
}
}
-#endif // DCHECK_IS_CONFIGURABLE
+#endif // defined(DCHECK_IS_CONFIGURABLE)
#if defined(OS_FUCHSIA)
TEST_F(LoggingTest, FuchsiaLogging) {
@@ -829,6 +829,63 @@ TEST_F(LoggingTest, LogPrefix) {
log_string_ptr = nullptr;
}
+// Crashes on Win 10 only. https://crbug.com/897735
+#if defined(OS_WIN)
+#define MAYBE_LogMessageMarkersOnStack DISABLED_LogMessageMarkersOnStack
+#else
+#define MAYBE_LogMessageMarkersOnStack LogMessageMarkersOnStack
+#endif
+
+#if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER)
+// Since we scan potentially uninitialized portions of the stack, we can't run
+// this test under any sanitizer that checks for uninitialized reads.
+TEST_F(LoggingTest, MAYBE_LogMessageMarkersOnStack) {
+ const uint32_t kLogStartMarker = 0xbedead01;
+ const uint32_t kLogEndMarker = 0x5050dead;
+ const char kTestMessage[] = "Oh noes! I have crashed! 💩";
+
+ uint32_t stack_start = 0;
+
+ // Install a LogAssertHandler which will scan between |stack_start| and its
+ // local-scope stack for the start & end markers, and verify the message.
+ ScopedLogAssertHandler assert_handler(base::BindRepeating(
+ [](uint32_t* stack_start_ptr, const char* file, int line,
+ const base::StringPiece message, const base::StringPiece stack_trace) {
+ uint32_t stack_end;
+ uint32_t* stack_end_ptr = &stack_end;
+
+ // Scan the stack for the expected markers.
+ uint32_t* start_marker = nullptr;
+ uint32_t* end_marker = nullptr;
+ for (uint32_t* ptr = stack_end_ptr; ptr <= stack_start_ptr; ++ptr) {
+ if (*ptr == kLogStartMarker)
+ start_marker = ptr;
+ else if (*ptr == kLogEndMarker)
+ end_marker = ptr;
+ }
+
+ // Verify that start & end markers were found, somewhere, in-between
+ // this and the LogAssertHandler scope, in the LogMessage destructor's
+ // stack frame.
+ ASSERT_TRUE(start_marker);
+ ASSERT_TRUE(end_marker);
+
+ // Verify that the |message| is found in-between the markers.
+ const char* start_char_marker =
+ reinterpret_cast<char*>(start_marker + 1);
+ const char* end_char_marker = reinterpret_cast<char*>(end_marker);
+
+ const base::StringPiece stack_view(start_char_marker,
+ end_char_marker - start_char_marker);
+ ASSERT_FALSE(stack_view.find(message) == base::StringPiece::npos);
+ },
+ &stack_start));
+
+ // Trigger a log assertion, with a test message we can check for.
+ LOG(FATAL) << kTestMessage;
+}
+#endif // !defined(ADDRESS_SANITIZER)
+
} // namespace
} // namespace logging