Commit f98bb7f5 authored by kouhei@chromium.org's avatar kouhei@chromium.org

LeakDetector: Add commandline option to force crash when leak is found.

This CL modifies the LeakDetector to force immediate crash when an
optional commandline argument is specified to content_shell.

Usage:
$ content_shell --dump-render-tree --enable-leak-detection=crash-on-failure

This enables us to use the ClusterFuzz infrastructure to investigate and
minimize leaks, as the tool currently detects the test case pass/fail by
seeing if the process crashes.

BUG=None

Review URL: https://codereview.chromium.org/405433011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284064 0039d316-1c4b-4281-b951-d872f2087c98
parent 119ac96a
...@@ -228,8 +228,12 @@ void ShellContentBrowserClient::AppendExtraCommandLineSwitches( ...@@ -228,8 +228,12 @@ void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kCrashDumpsDir)); switches::kCrashDumpsDir));
} }
if (CommandLine::ForCurrentProcess()->HasSwitch( if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableLeakDetection)) switches::kEnableLeakDetection)) {
command_line->AppendSwitch(switches::kEnableLeakDetection); command_line->AppendSwitchASCII(
switches::kEnableLeakDetection,
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kEnableLeakDetection));
}
if (CommandLine::ForCurrentProcess()->HasSwitch( if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kRegisterFontFiles)) { switches::kRegisterFontFiles)) {
command_line->AppendSwitchASCII( command_line->AppendSwitchASCII(
......
...@@ -202,9 +202,18 @@ WebKitTestController::WebKitTestController() ...@@ -202,9 +202,18 @@ WebKitTestController::WebKitTestController()
: main_window_(NULL), : main_window_(NULL),
test_phase_(BETWEEN_TESTS), test_phase_(BETWEEN_TESTS),
is_leak_detection_enabled_(CommandLine::ForCurrentProcess()->HasSwitch( is_leak_detection_enabled_(CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableLeakDetection)) { switches::kEnableLeakDetection)),
crash_when_leak_found_(false) {
CHECK(!instance_); CHECK(!instance_);
instance_ = this; instance_ = this;
if (is_leak_detection_enabled_) {
std::string switchValue =
CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kEnableLeakDetection);
crash_when_leak_found_ = switchValue == switches::kCrashOnFailure;
}
printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr)); printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr));
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEncodeBinary)) if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEncodeBinary))
printer_->set_encode_binary_data(true); printer_->set_encode_binary_data(true);
...@@ -680,6 +689,8 @@ void WebKitTestController::OnLeakDetectionDone( ...@@ -680,6 +689,8 @@ void WebKitTestController::OnLeakDetectionDone(
printer_->AddErrorMessage( printer_->AddErrorMessage(
base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_, base::StringPrintf("#LEAK - renderer pid %d (%s)", current_pid_,
result.detail.c_str())); result.detail.c_str()));
CHECK(!crash_when_leak_found_);
DiscardMainWindow(); DiscardMainWindow();
} }
......
...@@ -212,6 +212,7 @@ class WebKitTestController : public base::NonThreadSafe, ...@@ -212,6 +212,7 @@ class WebKitTestController : public base::NonThreadSafe,
NotificationRegistrar registrar_; NotificationRegistrar registrar_;
const bool is_leak_detection_enabled_; const bool is_leak_detection_enabled_;
bool crash_when_leak_found_;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Because of the nested message pump implementation, Android needs to allow // Because of the nested message pump implementation, Android needs to allow
......
...@@ -21,6 +21,10 @@ const char kContentShellDataPath[] = "data-path"; ...@@ -21,6 +21,10 @@ const char kContentShellDataPath[] = "data-path";
// The directory breakpad should store minidumps in. // The directory breakpad should store minidumps in.
const char kCrashDumpsDir[] = "crash-dumps-dir"; const char kCrashDumpsDir[] = "crash-dumps-dir";
// When specified to "enable-leak-detection" command-line option,
// causes the leak detector to cause immediate crash when found leak.
const char kCrashOnFailure[] = "crash-on-failure";
// Request pages to be dumped as text once they finished loading. // Request pages to be dumped as text once they finished loading.
const char kDumpRenderTree[] = "dump-render-tree"; const char kDumpRenderTree[] = "dump-render-tree";
......
...@@ -14,6 +14,7 @@ extern const char kCheckLayoutTestSysDeps[]; ...@@ -14,6 +14,7 @@ extern const char kCheckLayoutTestSysDeps[];
extern const char kContentBrowserTest[]; extern const char kContentBrowserTest[];
extern const char kContentShellDataPath[]; extern const char kContentShellDataPath[];
extern const char kCrashDumpsDir[]; extern const char kCrashDumpsDir[];
extern const char kCrashOnFailure[];
extern const char kDumpRenderTree[]; extern const char kDumpRenderTree[];
extern const char kEnableAccelerated2DCanvas[]; extern const char kEnableAccelerated2DCanvas[];
extern const char kEnableFontAntialiasing[]; extern const char kEnableFontAntialiasing[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment