diff options
author | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 09:44:59 +0000 |
---|---|---|
committer | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 09:44:59 +0000 |
commit | 9356b47bd6c96c45d7582bab5ee5f2e112c5dbc8 (patch) | |
tree | a047aca6a819bdf41b715cd4aec01a9dd9221ea1 /tools | |
parent | 1717b4f78826bbb64ebe099599427e1310da11b3 (diff) | |
download | chromium_src-9356b47bd6c96c45d7582bab5ee5f2e112c5dbc8.zip chromium_src-9356b47bd6c96c45d7582bab5ee5f2e112c5dbc8.tar.gz chromium_src-9356b47bd6c96c45d7582bab5ee5f2e112c5dbc8.tar.bz2 |
Print out the ui_test test case in the reports
TEST=ran memcheck and tsan locally on RedirectTest.Server with suppression files removed
Review URL: http://codereview.chromium.org/8539007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109602 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/valgrind/memcheck_analyze.py | 13 | ||||
-rw-r--r-- | tools/valgrind/tsan_analyze.py | 11 | ||||
-rwxr-xr-x | tools/valgrind/valgrind_test.py | 28 |
3 files changed, 40 insertions, 12 deletions
diff --git a/tools/valgrind/memcheck_analyze.py b/tools/valgrind/memcheck_analyze.py index 7823c44..c967281 100755 --- a/tools/valgrind/memcheck_analyze.py +++ b/tools/valgrind/memcheck_analyze.py @@ -115,7 +115,7 @@ class ValgrindError: ValgrindError is immutable and is hashed on its pretty printed output. ''' - def __init__(self, source_dir, error_node, commandline): + def __init__(self, source_dir, error_node, commandline, testcase): ''' Copies all the relevant information out of the DOM and into object properties. @@ -123,6 +123,7 @@ class ValgrindError: error_node: The <error></error> DOM node we're extracting from. source_dir: Prefix that should be stripped from the <dir> node. commandline: The command that was run under valgrind + testcase: The test case name, if known. ''' # Valgrind errors contain one <what><stack> pair, plus an optional @@ -194,6 +195,7 @@ class ValgrindError: self._backtraces = [] self._suppression = None self._commandline = commandline + self._testcase = testcase # Iterate through the nodes, parsing <what|auxwhat><stack> pairs. description = None @@ -260,6 +262,8 @@ class ValgrindError: assert self._suppression != None, "Your Valgrind doesn't generate " \ "suppressions - is it too old?" + if self._testcase: + output += "The report came from the `%s` test.\n" % self._testcase output += "Suppression (error hash=#%016X#):\n" % self.ErrorHash() output += (" For more info on using suppressions see " "http://dev.chromium.org/developers/how-tos/using-valgrind#TOC-Suppressing-Errors") @@ -398,7 +402,7 @@ class MemcheckAnalyzer: self._analyze_start_time = None - def Report(self, files, check_sanity=False): + def Report(self, files, testcase, check_sanity=False): '''Reads in a set of files and prints Memcheck report. Args: @@ -524,7 +528,8 @@ class MemcheckAnalyzer: # Ignore "possible" leaks for now by default. if (self._show_all_leaks or getTextOf(raw_error, "kind") != "Leak_PossiblyLost"): - error = ValgrindError(self._source_dir, raw_error, commandline) + error = ValgrindError(self._source_dir, + raw_error, commandline, testcase) if error not in cur_report_errors: # We haven't seen such errors doing this report yet... if error in self._errors: @@ -615,7 +620,7 @@ def _main(): filenames = args analyzer = MemcheckAnalyzer(options.source_dir, use_gdb=True) - retcode = analyzer.Report(filenames) + retcode = analyzer.Report(filenames, None) sys.exit(retcode) diff --git a/tools/valgrind/tsan_analyze.py b/tools/valgrind/tsan_analyze.py index e35d3e1..195ec1b 100644 --- a/tools/valgrind/tsan_analyze.py +++ b/tools/valgrind/tsan_analyze.py @@ -121,6 +121,9 @@ class TsanAnalyzer(object): self.ReadLine() supp += self.line_ self.ReadLine() + if self._cur_testcase: + result.append("The report came from the `%s` test.\n" % \ + self._cur_testcase) result.append("Suppression (error hash=#%016X#):\n" % \ (int(hashlib.md5(supp).hexdigest()[:16], 16))) result.append(" For more info on using suppressions see " @@ -213,7 +216,7 @@ class TsanAnalyzer(object): reports = map(lambda(x): map(str, x), reports) return [''.join(report_lines) for report_lines in reports] - def Report(self, files, check_sanity=False): + def Report(self, files, testcase, check_sanity=False): '''Reads in a set of files and prints ThreadSanitizer report. Args: @@ -221,7 +224,11 @@ class TsanAnalyzer(object): check_sanity: if true, search for SANITY_TEST_SUPPRESSIONS ''' + # We set up _cur_testcase class-wide variable to avoid passing it through + # about 5 functions. + self._cur_testcase = testcase reports = self.GetReports(files) + self._cur_testcase = None # just in case, shouldn't be used anymore is_sane = False print "-----------------------------------------------------" @@ -265,6 +272,6 @@ if __name__ == '__main__': filenames = args analyzer = TsanAnalyzer(options.source_dir, use_gdb=True) - retcode = analyzer.Report(filenames) + retcode = analyzer.Report(filenames, None) sys.exit(retcode) diff --git a/tools/valgrind/valgrind_test.py b/tools/valgrind/valgrind_test.py index 88293c8..f1651fb 100755 --- a/tools/valgrind/valgrind_test.py +++ b/tools/valgrind/valgrind_test.py @@ -397,7 +397,12 @@ class ValgrindTool(BaseTool): text=True) f = os.fdopen(fd, "w") f.write("#!/bin/sh\n") - f.write('echo "Started Valgrind wrapper for this test, PID=$$"\n') + f.write('echo "Started Valgrind wrapper for this test, PID=$$"\n\n') + f.write('for arg in $@\ndo\n') + f.write(' if [[ "$arg" =~ --test-name=(.*) ]]\n then\n') + f.write(' TESTCASE=${BASH_REMATCH[1]}\n') + f.write(' echo $TESTCASE >`dirname $0`/testcase.$$.name\n') + f.write(' fi\ndone\n') # Add the PID of the browser wrapper to the logfile names so we can # separate log files for different UI tests at the analyze stage. f.write(command) @@ -423,21 +428,31 @@ class ValgrindTool(BaseTool): analyzer = self.CreateAnalyzer() if len(ppids) == 0: # Fast path - no browser wrapper was set. - return analyzer.Report(filenames, check_sanity) + return analyzer.Report(filenames, None, check_sanity) ret = 0 for ppid in ppids: + testcase_name = None + try: + f = open(self.log_dir + ("/testcase.%d.name" % ppid)) + testcase_name = f.read().strip() + f.close() + except IOError: + pass print "=====================================================" print " Below is the report for valgrind wrapper PID=%d." % ppid - print " You can find the corresponding test" - print " by searching the above log for 'PID=%d'" % ppid + if testcase_name: + print " It was used while running the `%s` test." % testcase_name + else: + print " You can find the corresponding test" + print " by searching the above log for 'PID=%d'" % ppid sys.stdout.flush() ppid_filenames = [f for f in filenames \ if re.search("\.%d\.[0-9]+$" % ppid, f)] # check_sanity won't work with browser wrappers assert check_sanity == False - ret |= analyzer.Report(ppid_filenames) + ret |= analyzer.Report(ppid_filenames, testcase_name) print "=====================================================" sys.stdout.flush() @@ -446,6 +461,7 @@ class ValgrindTool(BaseTool): print "The Valgrind reports are grouped by test names." print "Each test has its PID printed in the log when the test was run" print "and at the beginning of its Valgrind report." + print "Hint: you can search for the reports by Ctrl+F -> `=#`" sys.stdout.flush() return ret @@ -700,7 +716,7 @@ class ThreadSanitizerWindows(ThreadSanitizerBase, PinTool): def Analyze(self, check_sanity=False): filenames = glob.glob(self.log_dir + "/tsan.*") analyzer = tsan_analyze.TsanAnalyzer(self._source_dir) - ret = analyzer.Report(filenames, check_sanity) + ret = analyzer.Report(filenames, None, check_sanity) if ret != 0: logging.info(self.INFO_MESSAGE) return ret |