summaryrefslogtreecommitdiffstats
path: root/chrome/common/logging_chrome_uitest.cc
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 04:30:14 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-18 04:30:14 +0000
commit54823b0f1ec8d65bf64423a64f727bbc8eb023a1 (patch)
treed8cabd5ef2f1413201b930520b923985db5caf25 /chrome/common/logging_chrome_uitest.cc
parent538ddce9c0e36665f2d34b6f7a731407afbcb554 (diff)
downloadchromium_src-54823b0f1ec8d65bf64423a64f727bbc8eb023a1.zip
chromium_src-54823b0f1ec8d65bf64423a64f727bbc8eb023a1.tar.gz
chromium_src-54823b0f1ec8d65bf64423a64f727bbc8eb023a1.tar.bz2
In release mode, trigger a SIGABRT rather than a SIGTRAP for fatal log errors, i.e. CHECK(false). Also enable tests to make sure we assert/crash as expected.
BUG=none TEST=Chrome in release mode generates crash dumps when CHECK() fails. See UI tests: AssertionTest.*:CheckFalseTest.*:RendererCrashTest.* Review URL: http://codereview.chromium.org/830003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/logging_chrome_uitest.cc')
-rw-r--r--chrome/common/logging_chrome_uitest.cc76
1 files changed, 65 insertions, 11 deletions
diff --git a/chrome/common/logging_chrome_uitest.cc b/chrome/common/logging_chrome_uitest.cc
index 1e75c66..ae6d6c8 100644
--- a/chrome/common/logging_chrome_uitest.cc
+++ b/chrome/common/logging_chrome_uitest.cc
@@ -2,11 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <string>
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
+#endif
+
+#include <string>
-#include "base/command_line.h"
#include "base/basictypes.h"
+#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/logging_chrome.h"
@@ -14,6 +19,8 @@
#include "chrome/test/ui/ui_test.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(OS_WIN)
+// TODO(port)
namespace {
class ChromeLoggingTest : public testing::Test {
public:
@@ -62,13 +69,22 @@ TEST_F(ChromeLoggingTest, EnvironmentLogFileName) {
RestoreEnvironmentVariable();
}
+#endif // defined(OS_WIN)
+
+#if defined(OS_LINUX) && (!defined(NDEBUG) || !defined(USE_LINUX_BREAKPAD))
+// On Linux in Debug mode, Chrome generates a SIGTRAP.
+// we do not catch SIGTRAPs, thus no crash dump.
+// This also does not work if Breakpad is disabled.
+#define EXPECTED_ASSERT_CRASHES 0
+#else
+#define EXPECTED_ASSERT_CRASHES 1
+#endif
-#ifndef NDEBUG // We don't have assertions in release builds.
+#if !defined(NDEBUG) // We don't have assertions in release builds.
// Tests whether we correctly fail on browser assertions during tests.
class AssertionTest : public UITest {
protected:
- AssertionTest() : UITest()
- {
+ AssertionTest() : UITest() {
// Initial loads will never complete due to assertion.
wait_for_initial_loads_ = false;
@@ -80,23 +96,54 @@ class AssertionTest : public UITest {
};
// Launch the app in assertion test mode, then close the app.
-TEST_F(AssertionTest, DISABLED_Assertion) {
+#if defined(OS_WIN)
+// http://crbug.com/26715
+#define Assertion DISABLED_Assertion
+#endif
+TEST_F(AssertionTest, Assertion) {
+ if (UITest::in_process_renderer()) {
+ // in process mode doesn't do the crashing.
+ expected_errors_ = 0;
+ expected_crashes_ = 0;
+ } else {
+ expected_errors_ = 1;
+ expected_crashes_ = EXPECTED_ASSERT_CRASHES;
+ }
+}
+#endif // !defined(NDEBUG)
+
+#if !defined(OFFICIAL_BUILD)
+// Only works on Linux in Release mode with CHROME_HEADLESS=1
+class CheckFalseTest : public UITest {
+ protected:
+ CheckFalseTest() : UITest() {
+ // Initial loads will never complete due to assertion.
+ wait_for_initial_loads_ = false;
+
+ // We're testing the renderer rather than the browser assertion here,
+ // because the browser assertion would flunk the test during SetUp()
+ // (since TAU wouldn't be able to find the browser window).
+ launch_arguments_.AppendSwitch(switches::kRendererCheckFalseTest);
+ }
+};
+
+// Launch the app in assertion test mode, then close the app.
+TEST_F(CheckFalseTest, CheckFails) {
if (UITest::in_process_renderer()) {
// in process mode doesn't do the crashing.
expected_errors_ = 0;
expected_crashes_ = 0;
} else {
expected_errors_ = 1;
- expected_crashes_ = 1;
+ expected_crashes_ = EXPECTED_ASSERT_CRASHES;
}
}
-#endif // NDEBUG
+#endif // !defined(OFFICIAL_BUILD)
// Tests whether we correctly fail on browser crashes during UI Tests.
class RendererCrashTest : public UITest {
protected:
- RendererCrashTest() : UITest()
- {
+ RendererCrashTest() : UITest() {
// Initial loads will never complete due to crash.
wait_for_initial_loads_ = false;
@@ -104,6 +151,13 @@ class RendererCrashTest : public UITest {
}
};
+#if defined(OS_LINUX) && !defined(USE_LINUX_BREAKPAD)
+// On Linux, do not expect a crash dump if Breakpad is disabled.
+#define EXPECTED_CRASH_CRASHES 0
+#else
+#define EXPECTED_CRASH_CRASHES 1
+#endif
+
#if defined(OS_WIN)
// http://crbug.com/32048
#define Crash FLAKY_Crash
@@ -117,6 +171,6 @@ TEST_F(RendererCrashTest, Crash) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
ASSERT_TRUE(browser.get());
ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms()));
- expected_crashes_ = 1;
+ expected_crashes_ = EXPECTED_CRASH_CRASHES;
}
}