summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 18:04:45 +0000
committerdkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 18:04:45 +0000
commitcea3dfdedf95788f9973bcce16fc9446e898af9e (patch)
tree958b582432ba5263a52c76327e863bd33703870c
parent7ef219e01e9ebfb0bddc40d431acaa2cacd432f0 (diff)
downloadchromium_src-cea3dfdedf95788f9973bcce16fc9446e898af9e.zip
chromium_src-cea3dfdedf95788f9973bcce16fc9446e898af9e.tar.gz
chromium_src-cea3dfdedf95788f9973bcce16fc9446e898af9e.tar.bz2
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
-rw-r--r--chrome/test/ui/ui_test.cc12
-rwxr-xr-xtools/valgrind/chrome_tests.py13
-rwxr-xr-xtools/valgrind/valgrind_test.py32
3 files changed, 54 insertions, 3 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 72d24b7..c4d4cbc 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -354,6 +354,18 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
!show_window_,
&process_);
#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(),
server_->fds_to_map(),
false, // Don't wait.
diff --git a/tools/valgrind/chrome_tests.py b/tools/valgrind/chrome_tests.py
index 608a1b5..0383cf45 100755
--- a/tools/valgrind/chrome_tests.py
+++ b/tools/valgrind/chrome_tests.py
@@ -136,6 +136,9 @@ class ChromeTests:
cmd.append("--show_all_leaks")
if self._options.generate_suppressions:
cmd.append("--generate_suppressions")
+ if exe == "ui_tests":
+ cmd.append("--trace_children")
+ cmd.append("--indirect")
if exe:
cmd.append(os.path.join(self._options.build_dir, exe))
# Valgrind runs tests slowly, so slow tests hurt more; show elapased time
@@ -174,9 +177,11 @@ class ChromeTests:
if 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)
self._ReadGtestFilterFile(name, cmd)
+ if cmd_args:
+ cmd.extend(cmd_args)
return common.RunSubprocess(cmd, 0)
def ScriptedTest(self, module, exe, name, script, multi=False, cmd_args=None,
@@ -245,7 +250,11 @@ class ChromeTests:
return self.SimpleTest("chrome", "unit_tests")
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):
# return self.TestLayout(run_all=True)
diff --git a/tools/valgrind/valgrind_test.py b/tools/valgrind/valgrind_test.py
index a108853..26f2be2 100755
--- a/tools/valgrind/valgrind_test.py
+++ b/tools/valgrind/valgrind_test.py
@@ -15,7 +15,9 @@ import logging
import optparse
import os
import shutil
+import stat
import sys
+import tempfile
import common
@@ -58,6 +60,12 @@ class Valgrind(object):
self._parser.add_option("", "--gtest_print_time", action="store_true",
default=False,
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",
default=False,
help="also show less blatant leaks")
@@ -177,6 +185,9 @@ class ValgrindLinux(Valgrind):
if self._options.show_all_leaks:
proc += ["--show-reachable=yes"];
+ if self._options.trace_children:
+ proc += ["--trace-children=yes"];
+
# Either generate suppressions or load them.
if self._generate_suppressions:
proc += ["--gen-suppressions=all"]
@@ -192,7 +203,26 @@ class ValgrindLinux(Valgrind):
if not suppression_count:
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