summaryrefslogtreecommitdiffstats
path: root/base/logging_test.cpp
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2016-09-07 10:10:50 -0700
committerAndreas Gampe <agampe@google.com>2016-09-07 18:19:42 -0700
commit550829d84bd403c9d29c003614962ee72a9a052d (patch)
tree8184043931104cfba8601ef020223635ddadd302 /base/logging_test.cpp
parentaf6a185fb44a30a0988688ff48e8e0fb104bf6c5 (diff)
downloadsystem_core-550829d84bd403c9d29c003614962ee72a9a052d.tar.gz
system_core-550829d84bd403c9d29c003614962ee72a9a052d.tar.bz2
system_core-550829d84bd403c9d29c003614962ee72a9a052d.zip
Base: Add INTERNAL_FATAL to logging severity
Add the INTERNAL_FATAL level. It will print 'F' like FATAL, but does not abort after logging. Add a test to logging_test. Bug: 31338270 Test: m Test: mmma system/core/base && adb sync && adb shell /data/nativetest/libbase_test/libbase_test32 Change-Id: Idf74c08e8516881efccaefc58fa3f41d57e56396
Diffstat (limited to 'base/logging_test.cpp')
-rw-r--r--base/logging_test.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/base/logging_test.cpp b/base/logging_test.cpp
index 6a321fce5..3fde302a3 100644
--- a/base/logging_test.cpp
+++ b/base/logging_test.cpp
@@ -122,7 +122,9 @@ TEST(logging, CHECK) {
static std::string make_log_pattern(android::base::LogSeverity severity,
const char* message) {
- static const char* log_characters = "VDIWEF";
+ static const char log_characters[] = "VDIWEFF";
+ static_assert(arraysize(log_characters) - 1 == android::base::FATAL + 1,
+ "Mismatch in size of log_characters and values in LogSeverity");
char log_char = log_characters[severity];
std::string holder(__FILE__);
return android::base::StringPrintf(
@@ -164,6 +166,14 @@ TEST(logging, LOG_FATAL) {
ASSERT_DEATH({SuppressAbortUI(); LOG(FATAL) << "foobar";}, "foobar");
}
+TEST(logging, LOG_FATAL_WITHOUT_ABORT_disabled) {
+ CHECK_LOG_DISABLED(FATAL_WITHOUT_ABORT);
+}
+
+TEST(logging, LOG_FATAL_WITHOUT_ABORT_enabled) {
+ CHECK_LOG_ENABLED(FATAL_WITHOUT_ABORT);
+}
+
TEST(logging, LOG_ERROR_disabled) {
CHECK_LOG_DISABLED(ERROR);
}
@@ -260,6 +270,18 @@ TEST(logging, LOG_does_not_have_dangling_if) {
PLOG(severity) << "foobar"; \
CheckMessage(cap2, android::base::severity, "foobar: No such file or directory"); \
+TEST(logging, PLOG_FATAL) {
+ ASSERT_DEATH({SuppressAbortUI(); PLOG(FATAL) << "foobar";}, "foobar");
+}
+
+TEST(logging, PLOG_FATAL_WITHOUT_ABORT_disabled) {
+ CHECK_PLOG_DISABLED(FATAL_WITHOUT_ABORT);
+}
+
+TEST(logging, PLOG_FATAL_WITHOUT_ABORT_enabled) {
+ CHECK_PLOG_ENABLED(FATAL_WITHOUT_ABORT);
+}
+
TEST(logging, PLOG_ERROR_disabled) {
CHECK_PLOG_DISABLED(ERROR);
}