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
diff --git a/base/logging_test.cpp b/base/logging_test.cpp
index 6a321fc..3fde302 100644
--- a/base/logging_test.cpp
+++ b/base/logging_test.cpp
@@ -122,7 +122,9 @@
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 @@
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 @@
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);
}