Commit cea3dfde authored by dkegel@google.com's avatar dkegel@google.com

When running ui_tests, need to tell valgrind to also trace child processes.

Also need to avoid valgrinding python.

Review URL: http://codereview.chromium.org/45053

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12572 0039d316-1c4b-4281-b951-d872f2087c98
parent 7ef219e0
...@@ -354,6 +354,18 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) { ...@@ -354,6 +354,18 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
!show_window_, !show_window_,
&process_); &process_);
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
// Sometimes one needs to run the browser under a special environment
// (e.g. valgrind) without also running the test harness (e.g. python)
// under the special environment. Provide a way to wrap the browser
// commandline with a special prefix to invoke the special environment.
const char* browser_wrapper = getenv("BROWSER_WRAPPER");
if (browser_wrapper) {
CommandLine wrapped_command(ASCIIToWide(browser_wrapper));
wrapped_command.AppendArguments(command_line, true);
command_line = wrapped_command;
LOG(INFO) << "BROWSER_WRAPPER was set, prefixing command_line with " << browser_wrapper;
}
bool started = base::LaunchApp(command_line.argv(), bool started = base::LaunchApp(command_line.argv(),
server_->fds_to_map(), server_->fds_to_map(),
false, // Don't wait. false, // Don't wait.
......
...@@ -136,6 +136,9 @@ class ChromeTests: ...@@ -136,6 +136,9 @@ class ChromeTests:
cmd.append("--show_all_leaks") cmd.append("--show_all_leaks")
if self._options.generate_suppressions: if self._options.generate_suppressions:
cmd.append("--generate_suppressions") cmd.append("--generate_suppressions")
if exe == "ui_tests":
cmd.append("--trace_children")
cmd.append("--indirect")
if exe: if exe:
cmd.append(os.path.join(self._options.build_dir, exe)) cmd.append(os.path.join(self._options.build_dir, exe))
# Valgrind runs tests slowly, so slow tests hurt more; show elapased time # Valgrind runs tests slowly, so slow tests hurt more; show elapased time
...@@ -174,9 +177,11 @@ class ChromeTests: ...@@ -174,9 +177,11 @@ class ChromeTests:
if gtest_filter: if gtest_filter:
cmd.append("--gtest_filter=%s" % gtest_filter) cmd.append("--gtest_filter=%s" % gtest_filter)
def SimpleTest(self, module, name): def SimpleTest(self, module, name, cmd_args=None):
cmd = self._DefaultCommand(module, name) cmd = self._DefaultCommand(module, name)
self._ReadGtestFilterFile(name, cmd) self._ReadGtestFilterFile(name, cmd)
if cmd_args:
cmd.extend(cmd_args)
return common.RunSubprocess(cmd, 0) return common.RunSubprocess(cmd, 0)
def ScriptedTest(self, module, exe, name, script, multi=False, cmd_args=None, def ScriptedTest(self, module, exe, name, script, multi=False, cmd_args=None,
...@@ -245,7 +250,11 @@ class ChromeTests: ...@@ -245,7 +250,11 @@ class ChromeTests:
return self.SimpleTest("chrome", "unit_tests") return self.SimpleTest("chrome", "unit_tests")
def TestUI(self): def TestUI(self):
return self.SimpleTest("chrome", "ui_tests") return self.SimpleTest("chrome", "ui_tests",
cmd_args=["--",
"--ui-test-timeout=120000",
"--ui-test-action-timeout=80000",
"--ui-test-action-max-timeout=180000"])
# def TestLayoutAll(self): # def TestLayoutAll(self):
# return self.TestLayout(run_all=True) # return self.TestLayout(run_all=True)
......
...@@ -15,7 +15,9 @@ import logging ...@@ -15,7 +15,9 @@ import logging
import optparse import optparse
import os import os
import shutil import shutil
import stat
import sys import sys
import tempfile
import common import common
...@@ -58,6 +60,12 @@ class Valgrind(object): ...@@ -58,6 +60,12 @@ class Valgrind(object):
self._parser.add_option("", "--gtest_print_time", action="store_true", self._parser.add_option("", "--gtest_print_time", action="store_true",
default=False, default=False,
help="show how long each test takes") help="show how long each test takes")
self._parser.add_option("", "--trace_children", action="store_true",
default=False,
help="also trace child processes")
self._parser.add_option("", "--indirect", action="store_true",
default=False,
help="set BROWSER_WRAPPER rather than running valgrind directly")
self._parser.add_option("", "--show_all_leaks", action="store_true", self._parser.add_option("", "--show_all_leaks", action="store_true",
default=False, default=False,
help="also show less blatant leaks") help="also show less blatant leaks")
...@@ -177,6 +185,9 @@ class ValgrindLinux(Valgrind): ...@@ -177,6 +185,9 @@ class ValgrindLinux(Valgrind):
if self._options.show_all_leaks: if self._options.show_all_leaks:
proc += ["--show-reachable=yes"]; proc += ["--show-reachable=yes"];
if self._options.trace_children:
proc += ["--trace-children=yes"];
# Either generate suppressions or load them. # Either generate suppressions or load them.
if self._generate_suppressions: if self._generate_suppressions:
proc += ["--gen-suppressions=all"] proc += ["--gen-suppressions=all"]
...@@ -192,7 +203,26 @@ class ValgrindLinux(Valgrind): ...@@ -192,7 +203,26 @@ class ValgrindLinux(Valgrind):
if not suppression_count: if not suppression_count:
logging.warning("WARNING: NOT USING SUPPRESSIONS!") logging.warning("WARNING: NOT USING SUPPRESSIONS!")
proc += ["--log-file=" + self.TMP_DIR + "/valgrind.%p"] + self._args proc += ["--log-file=" + self.TMP_DIR + "/valgrind.%p"]
if self._options.indirect:
# The program being run invokes Python or something else
# that can't stand to be valgrinded, and also invokes
# the Chrome browser. Set an environment variable to
# tell the program to prefix the Chrome commandline
# with a magic wrapper. Build the magic wrapper here.
(fd, indirect_fname) = tempfile.mkstemp(dir=self.TMP_DIR, prefix="browser_wrapper.", text=True)
f = os.fdopen(fd, "w");
f.write("#!/bin/sh\n")
f.write(" ".join(proc))
f.write(' "$@"\n')
f.close()
os.chmod(indirect_fname, stat.S_IRUSR|stat.S_IXUSR)
os.putenv("BROWSER_WRAPPER", indirect_fname)
logging.info('export BROWSER_WRAPPER=' + indirect_fname);
proc = []
proc += self._args
return proc return proc
......
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