diff options
author | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 14:26:02 +0000 |
---|---|---|
committer | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 14:26:02 +0000 |
commit | b24ca00f664f2b6d49ab8f0703de5b21c7dc2e46 (patch) | |
tree | 3280c6b538777b96a420293c19f8779277ac6845 | |
parent | 3c574d32859a78273e53dd6cc61724e9659240cf (diff) | |
download | chromium_src-b24ca00f664f2b6d49ab8f0703de5b21c7dc2e46.zip chromium_src-b24ca00f664f2b6d49ab8f0703de5b21c7dc2e46.tar.gz chromium_src-b24ca00f664f2b6d49ab8f0703de5b21c7dc2e46.tar.bz2 |
Add support for running Chromium tests under TSan in RaceVerifier mode.
The patch was prepared by Evgeniy Stepanov and
reviewed as http://codereview.chromium.org/3296016
TBR=glider
TEST=TSan bots shouldn't be affected by this for now
Review URL: http://codereview.chromium.org/3418003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59370 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | tools/valgrind/chrome_tests.py | 2 | ||||
-rwxr-xr-x | tools/valgrind/valgrind_test.py | 81 |
2 files changed, 76 insertions, 7 deletions
diff --git a/tools/valgrind/chrome_tests.py b/tools/valgrind/chrome_tests.py index ed37a67..b448715 100755 --- a/tools/valgrind/chrome_tests.py +++ b/tools/valgrind/chrome_tests.py @@ -409,7 +409,7 @@ def _main(_): "[-t <test> ...]") parser.disable_interspersed_args() parser.add_option("-b", "--build_dir", - help="the location of the output of the compiler output") + help="the location of the compiler output") parser.add_option("-t", "--test", action="append", default=[], help="which test to run, supports test:gtest_filter format " "as well.") diff --git a/tools/valgrind/valgrind_test.py b/tools/valgrind/valgrind_test.py index 39a4dd0..75c52d4 100755 --- a/tools/valgrind/valgrind_test.py +++ b/tools/valgrind/valgrind_test.py @@ -41,11 +41,6 @@ class BaseTool(object): TMP_DIR = "testing.tmp" def __init__(self): - # If we have a testing.tmp directory, we didn't cleanup last time. - if os.path.exists(self.TMP_DIR): - shutil.rmtree(self.TMP_DIR) - os.mkdir(self.TMP_DIR) - self.option_parser_hooks = [] def ToolName(self): @@ -775,6 +770,74 @@ class DrMemory(BaseTool): return ret +# RaceVerifier support. See +# http://code.google.com/p/data-race-test/wiki/RaceVerifier for more details. + +class ThreadSanitizerRV1Mixin(object): + """First pass: run ThreadSanitizer as usual, but don't clean up logs""" + + def ParseArgv(self, args): + ret = super(ThreadSanitizerRV1Mixin, self).ParseArgv(args) + self._nocleanup_on_exit = True + return ret + +class ThreadSanitizerRV2Mixin(object): + """Second pass: run the same command line in RaceVerifier mode""" + + def ToolSpecificFlags(self): + proc = super(ThreadSanitizerRV2Mixin, self).ToolSpecificFlags() + proc += ['--race-verifier=' + self.TMP_DIR + '/race.log'] + return proc + +class ThreadSanitizerRV1Posix(ThreadSanitizerRV1Mixin, ThreadSanitizerPosix): + pass + +class ThreadSanitizerRV2Posix(ThreadSanitizerRV2Mixin, ThreadSanitizerPosix): + pass + +class ThreadSanitizerRV1Windows(ThreadSanitizerRV1Mixin, + ThreadSanitizerWindows): + pass + +class ThreadSanitizerRV2Windows(ThreadSanitizerRV2Mixin, + ThreadSanitizerWindows): + pass + +class RaceVerifier(object): + """Runs tests under RaceVerifier/Valgrind.""" + + def RV1Factory(self): + if common.IsWindows(): + return ThreadSanitizerRV1Windows() + else: + return ThreadSanitizerRV1Posix() + + def RV2Factory(self): + if common.IsWindows(): + return ThreadSanitizerRV2Windows() + else: + return ThreadSanitizerRV2Posix() + + def JoinLogs(self): + """Concatenate all logs from the first pass""" + filenames = glob.glob(BaseTool.TMP_DIR + "/tsan" + ".*") + out_filename = BaseTool.TMP_DIR + "/race.log" + data = [open(fn, "r").read() for fn in filenames] + open(out_filename, "w").write("\n".join(data)) + + def Main(self, args, check_sanity): + cmd1 = self.RV1Factory() + ret = cmd1.Main(args, check_sanity) + # Verify race reports, if there are any. + if ret == -1: + self.JoinLogs() + cmd2 = self.RV2Factory() + ret = cmd2.Main(args, check_sanity) + else: + logging.info("No reports, skipping RaceVerifier step") + return ret + + class ToolFactory: def Create(self, tool_name): if tool_name == "memcheck" and not common.IsWine(): @@ -783,12 +846,13 @@ class ToolFactory: return Memcheck() if tool_name == "tsan": if common.IsWindows(): - logging.info("WARNING: ThreadSanitizer on Windows is experimental.") return ThreadSanitizerWindows() else: return ThreadSanitizerPosix() if tool_name == "drmemory": return DrMemory() + if tool_name == "tsan_rv": + return RaceVerifier() try: platform_name = common.PlatformNames()[0] except common.NotImplementedError: @@ -797,6 +861,11 @@ class ToolFactory: platform_name) def RunTool(argv, module): + # If we have a testing.tmp directory, we didn't cleanup last time. + if os.path.exists(BaseTool.TMP_DIR): + shutil.rmtree(BaseTool.TMP_DIR) + os.mkdir(BaseTool.TMP_DIR) + # TODO(timurrrr): customize optparse instead tool_name = "memcheck" args = argv[1:] |