diff options
author | Andreas Gampe <agampe@google.com> | 2016-10-04 19:17:07 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2016-10-04 19:19:59 -0700 |
commit | b4e32f3b33eb1d43d81b01e6f5f0815ced3f5e5b (patch) | |
tree | 766ea0812050fe8073706d86cc4ecf0587c93f38 /base/logging_test.cpp | |
parent | 1f90485804c6d21018d947531c9495bb42d4ea50 (diff) | |
download | system_core-b4e32f3b33eb1d43d81b01e6f5f0815ced3f5e5b.tar.gz system_core-b4e32f3b33eb1d43d81b01e6f5f0815ced3f5e5b.tar.bz2 system_core-b4e32f3b33eb1d43d81b01e6f5f0815ced3f5e5b.zip |
Base: Hand complete log message to aborter
Undo zero-termination-substitution for linebreaks when logging.
This results in handing the complete log message to the aborter.
Add a test.
Bug: 31893081
Test: mmma system/core/base && $ANDROID_HOST_OUT/nativetest64/libbase_test/libbase_test64
Change-Id: I2ef6c6351db2fd494a02985f634f439104136227
Diffstat (limited to 'base/logging_test.cpp')
-rw-r--r-- | base/logging_test.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/base/logging_test.cpp b/base/logging_test.cpp index 9fc77368f..1ee181a42 100644 --- a/base/logging_test.cpp +++ b/base/logging_test.cpp @@ -606,3 +606,27 @@ TEST(logging, LOG_FATAL_NOOP_ABORTER) { ASSERT_DEATH({SuppressAbortUI(); LOG(FATAL) << "foobar";}, "foobar"); } + +struct CountLineAborter { + static void CountLineAborterFunction(const char* msg) { + while (*msg != 0) { + if (*msg == '\n') { + newline_count++; + } + msg++; + } + } + static size_t newline_count; +}; +size_t CountLineAborter::newline_count = 0; + +TEST(logging, LOG_FATAL_ABORTER_MESSAGE) { + CountLineAborter::newline_count = 0; + android::base::SetAborter(CountLineAborter::CountLineAborterFunction); + + android::base::ScopedLogSeverity sls(android::base::ERROR); + CapturedStderr cap; + LOG(FATAL) << "foo\nbar"; + + EXPECT_EQ(CountLineAborter::newline_count, 1U + 1U); // +1 for final '\n'. +} |