summaryrefslogtreecommitdiffstats
path: root/tools/purify
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-06 00:09:18 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-06 00:09:18 +0000
commitdb4fe4cd35d8bb3bd9a6a85c09100482e6cd1047 (patch)
treed2d2973e89e311c66b1a22ef751193e7d5953728 /tools/purify
parent026e34a2adead1b6ab76ee2bb580ef33fc6bf63c (diff)
downloadchromium_src-db4fe4cd35d8bb3bd9a6a85c09100482e6cd1047.zip
chromium_src-db4fe4cd35d8bb3bd9a6a85c09100482e6cd1047.tar.gz
chromium_src-db4fe4cd35d8bb3bd9a6a85c09100482e6cd1047.tar.bz2
Allow purify scripts to take a --report_dir argument which specifies where the output data is written to.
Also, add a --buildbot flag which will default the report_dir to a specific directory on chrome-web. Review URL: http://codereview.chromium.org/20097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9286 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/purify')
-rw-r--r--tools/purify/chrome_tests.py33
-rw-r--r--tools/purify/purify_analyze.py57
-rw-r--r--tools/purify/purify_test.py14
3 files changed, 76 insertions, 28 deletions
diff --git a/tools/purify/chrome_tests.py b/tools/purify/chrome_tests.py
index 78f675e..e3bc0c1 100644
--- a/tools/purify/chrome_tests.py
+++ b/tools/purify/chrome_tests.py
@@ -48,16 +48,40 @@ class ChromeTests:
script_dir = google.path_utils.ScriptDir()
utility = google.platform_utils.PlatformUtility(script_dir)
+
# Compute the top of the tree (the "source dir") from the script dir (where
# this script lives). We assume that the script dir is in tools/purify
# relative to the top of the tree.
self._source_dir = os.path.dirname(os.path.dirname(script_dir))
+
# since this path is used for string matching, make sure it's always
# an absolute Windows-style path
self._source_dir = utility.GetAbsolutePath(self._source_dir)
+
+ self._report_dir = options.report_dir
+ if not self._report_dir:
+ if not options.buildbot:
+ self._report_dir = os.path.join(script_dir, "latest")
+ else:
+ # On the buildbot, we archive to a specific location on chrome-web
+ # with a directory based on the test name and the current svn revision.
+ # NOTE: These modules are located in trunk/tools/buildbot, which is not
+ # in the default config. You'll need to check this out and add
+ # scripts/* to your PYTHONPATH to test outside of the buildbot.
+ import slave_utils
+ import chromium_config
+ chrome_web_dir = chromium_config.Archive.purify_test_result_archive
+ current_version = str(slave_utils.SubversionRevision(self._source_dir))
+ # This line is how the buildbot master figures out our directory.
+ print "last change:", current_version
+ self._report_dir = os.path.join(chrome_web_dir, test,current_version)
+ if not os.path.exists(self._report_dir):
+ os.makedirs(self._report_dir)
+
purify_test = os.path.join(script_dir, "purify_test.py")
self._command_preamble = ["python.exe", purify_test, "--echo_to_stdout",
"--source_dir=%s" % (self._source_dir),
+ "--report_dir=%s" % (self._report_dir),
"--save_cache"]
def _DefaultCommand(self, module, exe=None):
@@ -68,6 +92,7 @@ class ChromeTests:
self._data_dir = os.path.join(module_dir, "test", "data", "purify")
else:
self._data_dir = os.path.join(module_dir, "data", "purify")
+
if not self._options.build_dir:
dir_chrome = os.path.join(self._source_dir, "chrome", "Release")
dir_module = os.path.join(module_dir, "Release")
@@ -297,8 +322,8 @@ class ChromeTests:
"--ui-test-timeout=180000",
"--ui-test-action-timeout=80000",
"--ui-test-action-max-timeout=180000",
- "--ui-test-sleep-timeout=40000"],
- multi=True)
+ "--ui-test-sleep-timeout=40000"],
+ multi=True)
def _main(argv):
@@ -321,6 +346,10 @@ def _main(argv):
help="run tests independently of each other so that they "
"don't interfere with each other and so that errors "
"can be accurately attributed to their source");
+ parser.add_option("", "--report_dir",
+ help="path where report files are saved")
+ parser.add_option("", "--buildbot", action="store_true", default=False,
+ help="whether we're being run in a buildbot environment")
options, args = parser.parse_args()
if options.verbose:
diff --git a/tools/purify/purify_analyze.py b/tools/purify/purify_analyze.py
index 0bbb5fc..070093c 100644
--- a/tools/purify/purify_analyze.py
+++ b/tools/purify/purify_analyze.py
@@ -163,22 +163,37 @@ class PurifyAnalyze:
types_excluded = ("EXH", "EXI", "EXC", "MPK")
- def __init__(self, files, echo, name=None, source_dir=None, data_dir=None):
+ def __init__(self, files, echo, name=None, source_dir=None, data_dir=None,
+ report_dir=None):
# The input file we're analyzing.
self._files = files
+
# Whether the input file contents should be echoed to stdout.
self._echo = echo
+
# A symbolic name for the run being analyzed, often the name of the
# exe which was purified.
self._name = name
+
# The top of the source code tree of the code we're analyzing.
# This prefix is stripped from all filenames in stacks for normalization.
if source_dir:
purify_message.Stack.SetSourceDir(source_dir)
+
+ script_dir = google.path_utils.ScriptDir()
+
if data_dir:
self._data_dir = data_dir
+ self._global_data_dir = os.path.join(script_dir, "data")
+ else:
+ self._data_dir = os.path.join(script_dir, "data")
+ self._global_data_dir = None
+
+ if report_dir:
+ self._report_dir = report_dir
else:
- self._data_dir = os.path.join(google.path_utils.ScriptDir(), "data")
+ self._report_dir = os.path.join(script_dir, "latest")
+
# A map of message_type to a MessageList of that type.
self._message_lists = {}
self._ReadIgnoreFile()
@@ -188,8 +203,9 @@ class PurifyAnalyze:
top-most visible stack line.
'''
self._pat_ignore = []
- filenames = [os.path.join(self._data_dir, "ignore.txt"),
- os.path.join(google.path_utils.ScriptDir(), "data", "ignore.txt")]
+ filenames = [os.path.join(self._data_dir, "ignore.txt")]
+ if self._global_data_dir:
+ filenames.append(os.path.join(self._global_data_dir, "ignore.txt"))
for filename in filenames:
if os.path.exists(filename):
f = open(filename, 'r')
@@ -595,12 +611,11 @@ class PurifyAnalyze:
print
sys.stdout.flush()
- def SaveLatestStrings(self, string_list, key, fname_extra=""):
- '''Output a list of strings to a file in the "latest" dir.
+ def SaveStrings(self, string_list, key, fname_extra=""):
+ '''Output a list of strings to a file in the report dir.
'''
- script_dir = google.path_utils.ScriptDir()
- path = os.path.join(script_dir, "latest")
- out = os.path.join(path, "%s_%s%s.txt" % (self._name, key, fname_extra))
+ out = os.path.join(self._report_dir,
+ "%s_%s%s.txt" % (self._name, key, fname_extra))
logging.info("saving %s" % (out))
try:
f = open(out, "w+")
@@ -617,7 +632,7 @@ class PurifyAnalyze:
type. See Message.NormalizedStr() for details of what's written.
'''
if not path:
- path = self._data_dir
+ path = self._report_dir
for key in self._message_lists:
out = os.path.join(path, "%s_%s.txt" % (self._name, key))
logging.info("saving %s" % (out))
@@ -698,8 +713,8 @@ class PurifyAnalyze:
logging.info("%s: %d msgs" % (filename, len(msgs)))
return msgs
- def _SaveLatestGroupSummary(self, message_list):
- '''Save a summary of message groups and their counts to a file in "latest"
+ def _SaveGroupSummary(self, message_list):
+ '''Save a summary of message groups and their counts to a file in report_dir
'''
string_list = []
groups = message_list.UniqueMessageGroups()
@@ -709,7 +724,7 @@ class PurifyAnalyze:
for group in group_keys:
string_list.append("%s: %d" % (group, len(groups[group])))
- self.SaveLatestStrings(string_list, message_list.GetType(), "_GROUPS")
+ self.SaveStrings(string_list, message_list.GetType(), "_GROUPS")
def CompareResults(self):
''' Compares the results from the current run with the baseline data
@@ -787,7 +802,7 @@ class PurifyAnalyze:
purify_message.GetMessageType(type), type,
'\n'.join(strs)))
strs = [current_hashes[x].NormalizedStr() for x in type_errors]
- self.SaveLatestStrings(strs, type, "_NEW")
+ self.SaveStrings(strs, type, "_NEW")
errors += len(type_errors)
if len(type_fixes):
@@ -796,17 +811,17 @@ class PurifyAnalyze:
logging.warning("%d new '%s(%s)' unexpected fixes found\n%s" % (
len(type_fixes), purify_message.GetMessageType(type),
type, '\n'.join(type_fixes)))
- self.SaveLatestStrings(type_fixes, type, "_FIXED")
+ self.SaveStrings(type_fixes, type, "_FIXED")
fixes += len(type_fixes)
if len(current_messages) == 0:
logging.warning("all errors fixed in %s" % baseline_file)
if len(type_fixes) or len(type_errors):
strs = [baseline_hashes[x] for x in new_baseline]
- self.SaveLatestStrings(strs, type, "_BASELINE")
+ self.SaveStrings(strs, type, "_BASELINE")
if current_list:
- self._SaveLatestGroupSummary(current_list)
+ self._SaveGroupSummary(current_list)
if errors:
logging.error("%d total new errors found" % errors)
@@ -852,6 +867,8 @@ def _main():
help="print output as an attempted summary of bugs")
parser.add_option("-v", "--verbose", action="store_true", default=False,
help="verbose output - enable debug log messages")
+ parser.add_option("", "--report_dir",
+ help="path where report files are saved")
(options, args) = parser.parse_args()
if not len(args) >= 1:
@@ -863,7 +880,7 @@ def _main():
else:
google.logging_utils.config_root(level=logging.INFO)
pa = PurifyAnalyze(filenames, options.echo_to_stdout, options.name,
- options.source_dir, options.data_dir)
+ options.source_dir, options.data_dir, options.report_dir)
execute_crash = not pa.ReadFile()
if options.bug_report:
pa.PrintBugReport()
@@ -876,9 +893,7 @@ def _main():
elif options.validate:
if pa.CompareResults() != 0:
retcode = -1
- script_dir = google.path_utils.ScriptDir()
- latest_dir = os.path.join(script_dir, "latest")
- pa.SaveResults(latest_dir)
+ pa.SaveResults()
pa.PrintSummary()
elif options.baseline:
if not pa.SaveResults(verbose=True):
diff --git a/tools/purify/purify_test.py b/tools/purify/purify_test.py
index c4798cef..98cad33 100644
--- a/tools/purify/purify_test.py
+++ b/tools/purify/purify_test.py
@@ -59,7 +59,9 @@ class Purify(common.Rational):
"is useful when the exe you want to purify is "
"run by another script or program.")
self._parser.add_option("", "--data_dir",
- help="path to where purify data files live")
+ help="path where global purify data files live")
+ self._parser.add_option("", "--report_dir",
+ help="path where report files are saved")
def ParseArgv(self):
if common.Rational.ParseArgv(self):
@@ -74,9 +76,12 @@ class Purify(common.Rational):
self._name = self._options.name
if not self._name:
self._name = os.path.basename(self._exe)
+ self._report_dir = self._options.report_dir
+ if not self._report_dir:
+ self._report_dir = os.path.join(script_dir, "latest")
# _out_file can be set in common.Rational.ParseArgv
if not self._out_file:
- self._out_file = os.path.join(self._latest_dir, "%s.txt" % self._name)
+ self._out_file = os.path.join(self._report_dir, "%s.txt" % self._name)
self._source_dir = self._options.source_dir
self._data_dir = self._options.data_dir
if not self._data_dir:
@@ -90,7 +95,6 @@ class Purify(common.Rational):
def Setup(self):
script_dir = google.path_utils.ScriptDir()
- self._latest_dir = os.path.join(script_dir, "latest")
if common.Rational.Setup(self):
if self._instrument_only:
return True
@@ -189,7 +193,7 @@ class Purify(common.Rational):
return -1
pa = purify_analyze.PurifyAnalyze(out_files, self._echo_to_stdout,
self._name, self._source_dir,
- self._data_dir)
+ self._data_dir, self._report_dir)
if not pa.ReadFile():
# even though there was a fatal error during Purify, it's still useful
# to see the normalized output
@@ -207,7 +211,7 @@ class Purify(common.Rational):
else:
retcode = pa.CompareResults()
if retcode != 0:
- pa.SaveResults(self._latest_dir)
+ pa.SaveResults(self._report_dir)
pa.PrintSummary()
# with more than one output file, it's also important to emit the bug
# report which includes info on the arguments that generated each stack