diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-20 20:59:01 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-20 20:59:01 +0000 |
commit | 20960e074cf789825155f771e1c035df41cd0e75 (patch) | |
tree | 560b967c07210bda790dbeebf6174e3e971b5eb7 | |
parent | c4f7571e88637185eb79e598bd3b6301490a2255 (diff) | |
download | chromium_src-20960e074cf789825155f771e1c035df41cd0e75.zip chromium_src-20960e074cf789825155f771e1c035df41cd0e75.tar.gz chromium_src-20960e074cf789825155f771e1c035df41cd0e75.tar.bz2 |
Add a gyp flag to enable dcheck by default in release without
having the pass a flag. This will be used on the try bots.
BUG=96753
Review URL: http://codereview.chromium.org/7719007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102017 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/file_util_unittest.cc | 2 | ||||
-rw-r--r-- | base/logging.h | 15 | ||||
-rw-r--r-- | base/logging_unittest.cc | 16 | ||||
-rw-r--r-- | build/common.gypi | 7 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/prefs/incognito_mode_prefs_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_notifier_impl_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/sync/syncable/directory_backing_store_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/render_view_host_unittest.cc | 4 | ||||
-rw-r--r-- | ipc/ipc_fuzzing_tests.cc | 6 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 2 | ||||
-rw-r--r-- | net/socket/transport_client_socket_pool_unittest.cc | 19 | ||||
-rw-r--r-- | net/spdy/spdy_protocol_test.cc | 8 | ||||
-rw-r--r-- | ui/base/text/bytes_formatting_unittest.cc | 4 | ||||
-rw-r--r-- | ui/gfx/rect_unittest.cc | 4 |
16 files changed, 87 insertions, 23 deletions
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index c44b804..7b12fb8c 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -223,7 +223,7 @@ TEST_F(FileUtilTest, AppendToPath) { EXPECT_EQ(value.result, result); } -#ifdef NDEBUG +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) file_util::AppendToPath(NULL, L"path"); // asserts in debug mode #endif } diff --git a/base/logging.h b/base/logging.h index c18fada..d418315 100644 --- a/base/logging.h +++ b/base/logging.h @@ -619,16 +619,29 @@ enum { DEBUG_MODE = ENABLE_DLOG }; #if defined(NDEBUG) +BASE_EXPORT extern DcheckState g_dcheck_state; + +#if defined(DCHECK_ALWAYS_ON) + +#define DCHECK_IS_ON() true +#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL +const LogSeverity LOG_DCHECK = LOG_FATAL; + +#else + #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ COMPACT_GOOGLE_LOG_EX_ERROR_REPORT(ClassName , ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_ERROR_REPORT const LogSeverity LOG_DCHECK = LOG_ERROR_REPORT; -BASE_EXPORT extern DcheckState g_dcheck_state; #define DCHECK_IS_ON() \ ((::logging::g_dcheck_state == \ ::logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS) && \ LOG_IS_ON(DCHECK)) +#endif // defined(DCHECK_ALWAYS_ON) + #else // defined(NDEBUG) // On a regular debug build, we want to have DCHECKs enabled. diff --git a/base/logging_unittest.cc b/base/logging_unittest.cc index 5a2cb53..08d7830 100644 --- a/base/logging_unittest.cc +++ b/base/logging_unittest.cc @@ -197,16 +197,16 @@ TEST_F(LoggingTest, DebugLoggingReleaseBehavior) { TEST_F(LoggingTest, DcheckStreamsAreLazy) { MockLogSource mock_log_source; EXPECT_CALL(mock_log_source, Log()).Times(0); - -#if !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) - // Unofficial release build. +#if !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) && \ + !defined(DCHECK_ALWAYS_ON) + // Unofficial release build without dcheck enabled. g_dcheck_state = DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; DCHECK(mock_log_source.Log()) << mock_log_source.Log(); DPCHECK(mock_log_source.Log()) << mock_log_source.Log(); DCHECK_EQ(0, 0) << mock_log_source.Log(); DCHECK_EQ(mock_log_source.Log(), static_cast<const char*>(NULL)) << mock_log_source.Log(); -#endif // !defined(LOGGING_IS_OFFICIAL_BUILD) && defined(NDEBUG) +#endif } TEST_F(LoggingTest, Dcheck) { @@ -214,12 +214,18 @@ TEST_F(LoggingTest, Dcheck) { // Official build. EXPECT_FALSE(DCHECK_IS_ON()); EXPECT_FALSE(DLOG_IS_ON(DCHECK)); -#elif defined(NDEBUG) +#elif defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) // Unofficial release build. g_dcheck_state = ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; SetLogReportHandler(&LogSink); EXPECT_TRUE(DCHECK_IS_ON()); EXPECT_FALSE(DLOG_IS_ON(DCHECK)); +#elif defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) + // Unofficial release build with real DCHECKS. + g_dcheck_state = ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS; + SetLogAssertHandler(&LogSink); + EXPECT_TRUE(DCHECK_IS_ON()); + EXPECT_FALSE(DLOG_IS_ON(DCHECK)); #else // Unofficial debug build. SetLogAssertHandler(&LogSink); diff --git a/build/common.gypi b/build/common.gypi index a4ab78cf..f46ba16 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -135,6 +135,9 @@ # compilation. 'fastbuild%': 0, + # Set to 1 to enable dcheck in release without having to use the flag. + 'dcheck_always_on%': 0, + # Disable file manager component extension by default. 'file_manager_extension%': 0, @@ -318,6 +321,7 @@ 'webui_task_manager%': '<(webui_task_manager)', 'inside_chromium_build%': '<(inside_chromium_build)', 'fastbuild%': '<(fastbuild)', + 'dcheck_always_on%': '<(dcheck_always_on)', 'python_ver%': '<(python_ver)', 'armv7%': '<(armv7)', 'arm_neon%': '<(arm_neon)', @@ -931,6 +935,9 @@ }], ], # conditions for fastbuild. }], # fastbuild!=0 + ['dcheck_always_on!=0', { + 'defines': ['DCHECK_ALWAYS_ON=1'], + }], # dcheck_always_on!=0 ['selinux==1', { 'defines': ['CHROMIUM_SELINUX=1'], }], diff --git a/chrome/browser/chrome_browser_main_unittest.cc b/chrome/browser/chrome_browser_main_unittest.cc index c6bbe96..8dee45f 100644 --- a/chrome/browser/chrome_browser_main_unittest.cc +++ b/chrome/browser/chrome_browser_main_unittest.cc @@ -77,6 +77,11 @@ TEST_F(BrowserMainTest, WarmConnectionFieldTrial_Invalid) { bw.reset(ccbc.CreateBrowserMainParts(*params)); } ChromeBrowserMainParts* cbw = static_cast<ChromeBrowserMainParts*>(bw.get()); +#if defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) + EXPECT_DEATH(cbw->WarmConnectionFieldTrial(), + "Not a valid socket reuse policy group"); +#else EXPECT_DEBUG_DEATH(cbw->WarmConnectionFieldTrial(), "Not a valid socket reuse policy group"); +#endif } diff --git a/chrome/browser/prefs/incognito_mode_prefs_unittest.cc b/chrome/browser/prefs/incognito_mode_prefs_unittest.cc index 053f0bf..6ae6364 100644 --- a/chrome/browser/prefs/incognito_mode_prefs_unittest.cc +++ b/chrome/browser/prefs/incognito_mode_prefs_unittest.cc @@ -58,9 +58,17 @@ typedef IncognitoModePrefsTest IncognitoModePrefsDeathTest; TEST_F(IncognitoModePrefsDeathTest, GetAvailabilityBadValue) { prefs_.SetUserPref(prefs::kIncognitoModeAvailability, Value::CreateIntegerValue(-1)); +#if defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) + EXPECT_DEATH({ + IncognitoModePrefs::Availability availability = + IncognitoModePrefs::GetAvailability(&prefs_); + EXPECT_EQ(IncognitoModePrefs::ENABLED, availability); + }, ""); +#else EXPECT_DEBUG_DEATH({ IncognitoModePrefs::Availability availability = IncognitoModePrefs::GetAvailability(&prefs_); EXPECT_EQ(IncognitoModePrefs::ENABLED, availability); }, ""); +#endif } diff --git a/chrome/browser/prefs/pref_notifier_impl_unittest.cc b/chrome/browser/prefs/pref_notifier_impl_unittest.cc index b2387ab..1beb430c 100644 --- a/chrome/browser/prefs/pref_notifier_impl_unittest.cc +++ b/chrome/browser/prefs/pref_notifier_impl_unittest.cc @@ -104,13 +104,13 @@ TEST_F(PrefNotifierTest, AddAndRemovePrefObservers) { // Re-adding the same observer for the same pref doesn't change anything. // Skip this in debug mode, since it hits a DCHECK and death tests aren't // thread-safe. -#if defined(NDEBUG) +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) notifier.AddPrefObserver(pref_name, &obs1_); ASSERT_EQ(1u, notifier.CountObserver(pref_name, &obs1_)); ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs1_)); ASSERT_EQ(0u, notifier.CountObserver(pref_name, &obs2_)); ASSERT_EQ(0u, notifier.CountObserver(pref_name2, &obs2_)); -#endif // NDEBUG +#endif // Ensure that we can add the same observer to a different pref. notifier.AddPrefObserver(pref_name2, &obs1_); diff --git a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc index f05bc6f..dae6f85 100644 --- a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc +++ b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc @@ -1667,8 +1667,10 @@ TEST_F(DirectoryBackingStoreTest, Corruption) { // In release mode, we expect the sync database to nuke itself and start // over if it detects invalid/corrupted data. -#if defined(NDEBUG) +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) EXPECT_TRUE(dbs->BeginLoad()); +#elif defined(NDEBUG) && defined(DCHECK_ALWAYS_ON) + EXPECT_DEATH(dbs->BeginLoad(), "stmt_"); #else EXPECT_DEATH(dbs->BeginLoad(), "sqlite error"); #endif diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index f7f55c9..7adbf8a 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -97,7 +97,7 @@ TEST_F(AutomationProxyTest, GetBrowserWindowCount) { int window_count = 0; EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); EXPECT_EQ(1, window_count); -#ifdef NDEBUG +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) ASSERT_FALSE(automation()->GetBrowserWindowCount(NULL)); #endif } diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc index 293ebd8..8cb626d 100644 --- a/content/browser/renderer_host/render_view_host_unittest.cc +++ b/content/browser/renderer_host/render_view_host_unittest.cc @@ -143,7 +143,7 @@ TEST_F(RenderViewHostTest, StartDragging) { } // The test that follow trigger DCHECKS in debug build. -#if defined(NDEBUG) +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) // Test that when we fail to de-serialize a message, RenderViewHost calls the // ReceivedBadMessage() handler. @@ -182,4 +182,4 @@ TEST_F(RenderViewHostTest, BadMessageHandlerInputEventAck) { EXPECT_EQ(1, process()->bad_msg_count()); } -#endif // NDEBUG +#endif diff --git a/ipc/ipc_fuzzing_tests.cc b/ipc/ipc_fuzzing_tests.cc index c7076cc..d1a3c33 100644 --- a/ipc/ipc_fuzzing_tests.cc +++ b/ipc/ipc_fuzzing_tests.cc @@ -290,7 +290,7 @@ TEST_F(IPCFuzzingTest, SanityTest) { // In debug this triggers an assertion and in release it is ignored(!!). Right // after we generate another valid IPC to make sure framing is working // properly. -#ifdef NDEBUG +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) TEST_F(IPCFuzzingTest, MsgBadPayloadShort) { FuzzerClientListener listener; IPC::Channel chan(kFuzzerChannel, IPC::Channel::MODE_SERVER, @@ -314,7 +314,7 @@ TEST_F(IPCFuzzingTest, MsgBadPayloadShort) { EXPECT_TRUE(base::WaitForSingleProcess(server_process, 5000)); base::CloseProcessHandle(server_process); } -#endif // NDEBUG +#endif // This test uses a payload that has too many arguments, but so the payload // size is big enough so the unpacking routine does not generate an error as @@ -392,7 +392,7 @@ TEST_F(IPCFuzzingTest, MsgMapExMacro) { EXPECT_TRUE(server.OnMessageReceived(*msg)); delete msg; -#ifdef NDEBUG +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) // Test a bad message. msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassSI::ID, IPC::Message::PRIORITY_NORMAL); diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 6ea1be2..970b3b6 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -4103,7 +4103,7 @@ TEST(HttpCache, RangeGET_FastFlakyServer2) { RemoveMockTransaction(&transaction); } -#ifdef NDEBUG +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) // This test hits a NOTREACHED so it is a release mode only test. TEST(HttpCache, RangeGET_OK_LoadOnlyFromCache) { MockHttpCache cache; diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc index d57eed6..c262bfb 100644 --- a/net/socket/transport_client_socket_pool_unittest.cc +++ b/net/socket/transport_client_socket_pool_unittest.cc @@ -797,7 +797,13 @@ class RequestSocketCallback : public CallbackRunner< Tuple1<int> > { TestCompletionCallback callback_; }; -TEST_F(TransportClientSocketPoolTest, RequestTwice) { +// Disabled in release with dcheck : http://crbug.com/94501 +#if defined(DCHECK_ALWAYS_ON) +#define MAYBE_RequestTwice DISABLED_RequestTwice +#else +#define MAYBE_RequestTwice RequestTwice +#endif +TEST_F(TransportClientSocketPoolTest, MAYBE_RequestTwice) { ClientSocketHandle handle; RequestSocketCallback callback(&handle, &pool_); scoped_refptr<TransportSocketParams> dest(new TransportSocketParams( @@ -996,8 +1002,11 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketCancel) { // // Flaky on Mac + Linux - http://crbug.com/86550 // Flaky on ChromeOS - http://crbug.com/89273 +// Disabled in release with dcheck : http://crbug.com/94501 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) || defined(OS_LINUX) #define MAYBE_BackupSocketFailAfterStall FLAKY_BackupSocketFailAfterStall +#elif defined(DCHECK_ALWAYS_ON) +#define MAYBE_BackupSocketFailAfterStall DISABLED_BackupSocketFailAfterStall #else #define MAYBE_BackupSocketFailAfterStall BackupSocketFailAfterStall #endif @@ -1046,7 +1055,13 @@ TEST_F(TransportClientSocketPoolTest, MAYBE_BackupSocketFailAfterStall) { // Test the case where a socket took long enough to start the creation // of the backup socket and eventually completes, but the backup socket // fails. -TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterDelay) { +// Disabled in release with dcheck : http://crbug.com/94501 +#if defined(DCHECK_ALWAYS_ON) +#define MAYBE_BackupSocketFailAfterDelay DISABLED_BackupSocketFailAfterDelay +#else +#define MAYBE_BackupSocketFailAfterDelay BackupSocketFailAfterDelay +#endif +TEST_F(TransportClientSocketPoolTest, MAYBE_BackupSocketFailAfterDelay) { MockClientSocketFactory::ClientSocketType case_types[] = { // The first socket will connect, although delayed. MockClientSocketFactory::MOCK_DELAYED_CLIENT_SOCKET, diff --git a/net/spdy/spdy_protocol_test.cc b/net/spdy/spdy_protocol_test.cc index 8b620e2..e6e378f 100644 --- a/net/spdy/spdy_protocol_test.cc +++ b/net/spdy/spdy_protocol_test.cc @@ -239,13 +239,21 @@ TEST(SpdyProtocolDeathTest, TestDataFrame) { frame.set_stream_id(0); // TODO(mbelshe): implement EXPECT_DEBUG_DEATH on windows. #ifndef WIN32 +#if !defined(DCHECK_ALWAYS_ON) EXPECT_DEBUG_DEATH(frame.set_stream_id(~0), ""); +#else + EXPECT_DEATH(frame.set_stream_id(~0), ""); +#endif #endif EXPECT_FALSE(frame.is_control_frame()); frame.set_flags(0); #ifndef WIN32 +#if !defined(DCHECK_ALWAYS_ON) EXPECT_DEBUG_DEATH(frame.set_length(~0), ""); +#else + EXPECT_DEATH(frame.set_length(~0), ""); +#endif #endif EXPECT_EQ(0, frame.flags()); } diff --git a/ui/base/text/bytes_formatting_unittest.cc b/ui/base/text/bytes_formatting_unittest.cc index a214259..4130552 100644 --- a/ui/base/text/bytes_formatting_unittest.cc +++ b/ui/base/text/bytes_formatting_unittest.cc @@ -20,7 +20,7 @@ TEST(BytesFormattingTest, GetByteDisplayUnits) { {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE}, {10LL*1024*1024*1024*1024, DATA_UNITS_TEBIBYTE}, {~(1LL<<63), DATA_UNITS_PEBIBYTE}, -#ifdef NDEBUG +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) {-1, DATA_UNITS_BYTE}, #endif }; @@ -63,7 +63,7 @@ TEST(BytesFormattingTest, FormatBytes) { "1.9", "1.9 GB"}, {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "10.0", "10.0 GB"}, {100LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "100", "100 GB"}, -#ifdef NDEBUG +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) {-1, DATA_UNITS_BYTE, "", ""}, #endif }; diff --git a/ui/gfx/rect_unittest.cc b/ui/gfx/rect_unittest.cc index 6e99b0a..4ad3f74 100644 --- a/ui/gfx/rect_unittest.cc +++ b/ui/gfx/rect_unittest.cc @@ -26,9 +26,9 @@ TEST(RectTest, Contains) { {0, 0, 10, 10, 10, 5, false}, {0, 0, 10, 10, -1, -1, false}, {0, 0, 10, 10, 50, 50, false}, - #ifdef NDEBUG + #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) {0, 0, -10, -10, 0, 0, false}, - #endif // NDEBUG + #endif }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(contains_cases); ++i) { const ContainsCase& value = contains_cases[i]; |