Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2975)

Unified Diff: base/logging_unittest.cc

Issue 2954883002: Add dvlog_always_on to enable DVLOG without DEBUG and DCHECK option
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/logging.h ('k') | base/message_loop/incoming_task_queue.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging_unittest.cc
diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc
index 0a1fed40830af069c9a383ce9606b15e04220744..13c2e2a1a9cf422903aea9b9aa2d414f71ffba48 100644
--- a/base/logging_unittest.cc
+++ b/base/logging_unittest.cc
@@ -83,7 +83,7 @@ class MockLogAssertHandler {
TEST_F(LoggingTest, BasicLogging) {
MockLogSource mock_log_source;
EXPECT_CALL(mock_log_source, Log())
- .Times(DCHECK_IS_ON() ? 16 : 8)
+ .Times(DCHECK_IS_ON() || DVLOG_IS_ON() ? 16 : 8)
.WillRepeatedly(Return("log message"));
SetMinLogLevel(LOG_INFO);
@@ -371,7 +371,7 @@ TEST_F(LoggingTest, CheckCausesDistinctBreakpoints) {
#endif // OS_POSIX
TEST_F(LoggingTest, DebugLoggingReleaseBehavior) {
-#if DCHECK_IS_ON()
+#if DCHECK_IS_ON() || DVLOG_IS_ON()
int debug_only_variable = 1;
#endif
// These should avoid emitting references to |debug_only_variable|
@@ -385,7 +385,7 @@ TEST_F(LoggingTest, DebugLoggingReleaseBehavior) {
TEST_F(LoggingTest, DcheckStreamsAreLazy) {
MockLogSource mock_log_source;
EXPECT_CALL(mock_log_source, Log()).Times(0);
-#if DCHECK_IS_ON()
+#if DCHECK_IS_ON() || DVLOG_IS_ON()
DCHECK(true) << mock_log_source.Log();
DCHECK_EQ(0, 0) << mock_log_source.Log();
#else
@@ -479,6 +479,19 @@ TEST_F(LoggingTest, MAYBE_Dcheck) {
EXPECT_EQ(DCHECK_IS_ON() ? 2 : 0, g_log_sink_call_count);
}
+TEST_F(LoggingTest, Dvlog) {
+#if defined(NDEBUG) && !defined(DVLOG_ALWAYS_ON)
+ // Release build.
+ EXPECT_FALSE(DVLOG_IS_ON());
+#elif defined(NDEBUG) && defined(DVLOG_ALWAYS_ON)
+ // Release build with real DVLOGs
+ EXPECT_TRUE(DVLOG_IS_ON());
+#else
+ // Debug build.
+ EXPECT_TRUE(DVLOG_IS_ON());
+#endif
+}
+
TEST_F(LoggingTest, DcheckReleaseBehavior) {
int some_variable = 1;
// These should still reference |some_variable| so we don't get
« no previous file with comments | « base/logging.h ('k') | base/message_loop/incoming_task_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698