Loading base/include/android-base/logging.h +7 −8 Original line number Diff line number Diff line Loading @@ -202,12 +202,11 @@ class ErrnoRestorer { // Helper for CHECK_STRxx(s1,s2) macros. #define CHECK_STROP(s1, s2, sense) \ if (LIKELY((strcmp(s1, s2) == 0) == (sense))) \ ; \ else \ while (UNLIKELY((strcmp(s1, s2) == 0) != (sense))) \ ABORT_AFTER_LOG_FATAL \ LOG(FATAL) << "Check failed: " \ << "\"" << (s1) << "\"" \ ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \ ::android::base::FATAL, -1).stream() \ << "Check failed: " << "\"" << (s1) << "\"" \ << ((sense) ? " == " : " != ") << "\"" << (s2) << "\"" // Check for string (const char*) equality between s1 and s2, LOG(FATAL) if not. Loading base/logging_test.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,28 @@ TEST(logging, CHECK) { EXPECT_FALSE(flag) << "CHECK_STREQ probably has a dangling if with no else"; } TEST(logging, DCHECK) { if (android::base::kEnableDChecks) { ASSERT_DEATH({SuppressAbortUI(); DCHECK(false);}, "DCheck failed: false "); } DCHECK(true); if (android::base::kEnableDChecks) { ASSERT_DEATH({SuppressAbortUI(); DCHECK_EQ(0, 1);}, "DCheck failed: 0 == 1 "); } DCHECK_EQ(0, 0); if (android::base::kEnableDChecks) { ASSERT_DEATH({SuppressAbortUI(); DCHECK_STREQ("foo", "bar");}, R"(DCheck failed: "foo" == "bar")"); } DCHECK_STREQ("foo", "foo"); // No testing whether we have a dangling else, possibly. That's inherent to the if (constexpr) // setup we intentionally chose to force type-checks of debug code even in release builds (so // we don't get more bit-rot). } static std::string make_log_pattern(android::base::LogSeverity severity, const char* message) { static const char log_characters[] = "VDIWEFF"; Loading Loading
base/include/android-base/logging.h +7 −8 Original line number Diff line number Diff line Loading @@ -202,12 +202,11 @@ class ErrnoRestorer { // Helper for CHECK_STRxx(s1,s2) macros. #define CHECK_STROP(s1, s2, sense) \ if (LIKELY((strcmp(s1, s2) == 0) == (sense))) \ ; \ else \ while (UNLIKELY((strcmp(s1, s2) == 0) != (sense))) \ ABORT_AFTER_LOG_FATAL \ LOG(FATAL) << "Check failed: " \ << "\"" << (s1) << "\"" \ ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \ ::android::base::FATAL, -1).stream() \ << "Check failed: " << "\"" << (s1) << "\"" \ << ((sense) ? " == " : " != ") << "\"" << (s2) << "\"" // Check for string (const char*) equality between s1 and s2, LOG(FATAL) if not. Loading
base/logging_test.cpp +22 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,28 @@ TEST(logging, CHECK) { EXPECT_FALSE(flag) << "CHECK_STREQ probably has a dangling if with no else"; } TEST(logging, DCHECK) { if (android::base::kEnableDChecks) { ASSERT_DEATH({SuppressAbortUI(); DCHECK(false);}, "DCheck failed: false "); } DCHECK(true); if (android::base::kEnableDChecks) { ASSERT_DEATH({SuppressAbortUI(); DCHECK_EQ(0, 1);}, "DCheck failed: 0 == 1 "); } DCHECK_EQ(0, 0); if (android::base::kEnableDChecks) { ASSERT_DEATH({SuppressAbortUI(); DCHECK_STREQ("foo", "bar");}, R"(DCheck failed: "foo" == "bar")"); } DCHECK_STREQ("foo", "foo"); // No testing whether we have a dangling else, possibly. That's inherent to the if (constexpr) // setup we intentionally chose to force type-checks of debug code even in release builds (so // we don't get more bit-rot). } static std::string make_log_pattern(android::base::LogSeverity severity, const char* message) { static const char log_characters[] = "VDIWEFF"; Loading