diff options
author | jvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-19 20:37:13 +0000 |
---|---|---|
committer | jvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-19 20:37:13 +0000 |
commit | b0a39178d73b6592dcf24114e53947d070399bab (patch) | |
tree | 6040f2492ec4b1df365138d64fddcf392d0e2137 /tools/perf_expectations | |
parent | 49e44ddbb8a44bf21bd75ec086f661f04682548d (diff) | |
download | chromium_src-b0a39178d73b6592dcf24114e53947d070399bab.zip chromium_src-b0a39178d73b6592dcf24114e53947d070399bab.tar.gz chromium_src-b0a39178d73b6592dcf24114e53947d070399bab.tar.bz2 |
Refactor make_expectations to make it easier to override the base_url
and the expectations file. This will allow NaCl to DEPs in the whole
src/tools/perf_expectations directory, yet still have its own values.
Also ends up checking in NaCl perf expectation values...
BUG= http://code.google.com/p/nativeclient/issues/detail?id=1479
TEST= ./make_expectations && ./make_expectations -c ../nacl_perf_expectations.cfg (test placing the file in another directory)
Review URL: http://codereview.chromium.org/7409007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/perf_expectations')
-rw-r--r-- | tools/perf_expectations/PRESUBMIT.py | 7 | ||||
-rw-r--r-- | tools/perf_expectations/chromium_perf_expectations.cfg | 4 | ||||
-rwxr-xr-x | tools/perf_expectations/make_expectations.py | 17 | ||||
-rwxr-xr-x | tools/perf_expectations/tests/perf_expectations_unittest.py | 34 |
4 files changed, 44 insertions, 18 deletions
diff --git a/tools/perf_expectations/PRESUBMIT.py b/tools/perf_expectations/PRESUBMIT.py index 158a3fb..9dd408f 100644 --- a/tools/perf_expectations/PRESUBMIT.py +++ b/tools/perf_expectations/PRESUBMIT.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -14,11 +14,12 @@ UNIT_TESTS = [ ] PERF_EXPECTATIONS = 'tools/perf_expectations/perf_expectations.json' +CONFIG_FILE = 'tools/perf_expectations/chromium_perf_expectations.cfg' def CheckChangeOnUpload(input_api, output_api): run_tests = False for path in input_api.LocalPaths(): - if PERF_EXPECTATIONS == path: + if (PERF_EXPECTATIONS == path or CONFIG_FILE == path): run_tests = True output = [] @@ -32,7 +33,7 @@ def CheckChangeOnUpload(input_api, output_api): def CheckChangeOnCommit(input_api, output_api): run_tests = False for path in input_api.LocalPaths(): - if PERF_EXPECTATIONS == path: + if (PERF_EXPECTATIONS == path or CONFIG_FILE == path): run_tests = True output = [] diff --git a/tools/perf_expectations/chromium_perf_expectations.cfg b/tools/perf_expectations/chromium_perf_expectations.cfg new file mode 100644 index 0000000..4d3abe7 --- /dev/null +++ b/tools/perf_expectations/chromium_perf_expectations.cfg @@ -0,0 +1,4 @@ +{ + "base_url": "http://build.chromium.org/f/chromium/perf", + "perf_file": "perf_expectations.json" +} diff --git a/tools/perf_expectations/make_expectations.py b/tools/perf_expectations/make_expectations.py index bd6018a..fef237e 100755 --- a/tools/perf_expectations/make_expectations.py +++ b/tools/perf_expectations/make_expectations.py @@ -7,6 +7,7 @@ import hashlib import math import optparse +import os import re import subprocess import sys @@ -21,7 +22,7 @@ except ImportError: __version__ = '1.0' -DEFAULT_EXPECTATIONS_FILE = 'perf_expectations.json' +DEFAULT_CONFIG_FILE = 'chromium_perf_expectations.cfg' DEFAULT_VARIANCE = 0.05 USAGE = '' @@ -132,14 +133,22 @@ def Main(args): parser = optparse.OptionParser(usage=USAGE, version=__version__) parser.add_option('-v', '--verbose', action='store_true', default=False, help='enable verbose output') + parser.add_option('-c', '--config', dest='config_file', + default=DEFAULT_CONFIG_FILE, + help='set the config file to FILE', metavar='FILE') options, args = parser.parse_args(args) if options.verbose: print 'Verbose output enabled.' + config = ConvertJsonIntoDict(ReadFile(options.config_file)) + # Get the list of summaries for a test. - base_url = 'http://build.chromium.org/f/chromium/perf' - perf = ConvertJsonIntoDict(ReadFile(DEFAULT_EXPECTATIONS_FILE)) + base_url = config['base_url'] + # Make the perf expectations file relative to the path of the config file. + perf_file = os.path.join( + os.path.dirname(options.config_file), config['perf_file']) + perf = ConvertJsonIntoDict(ReadFile(perf_file)) # Fetch graphs.dat for this combination. perfkeys = perf.keys() @@ -293,7 +302,7 @@ def Main(args): if write_new_expectations: print '\nWriting expectations... ', - WriteJson(DEFAULT_EXPECTATIONS_FILE, perf, perfkeys) + WriteJson(perf_file, perf, perfkeys) print 'done' else: if options.verbose: diff --git a/tools/perf_expectations/tests/perf_expectations_unittest.py b/tools/perf_expectations/tests/perf_expectations_unittest.py index ffb0e23..fc72415 100755 --- a/tools/perf_expectations/tests/perf_expectations_unittest.py +++ b/tools/perf_expectations/tests/perf_expectations_unittest.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -59,28 +59,30 @@ def OnTestsLoad(): sys.path = old_path return True -def LoadData(): - perf_file = open(PERF_EXPECTATIONS, 'r') +def LoadJsonFile(filename): + f = open(filename, 'r') try: - perf_data = simplejson.load(perf_file) + data = simplejson.load(f) except ValueError, e: - perf_file.seek(0) - print "Error reading %s:\n%s" % (PERF_EXPECTATIONS, - perf_file.read()[:50]+'...') + f.seek(0) + print "Error reading %s:\n%s" % (filename, + f.read()[:50]+'...') raise e - return perf_data + f.close() + return data OnTestsLoad() PERF_EXPECTATIONS = os.path.join(os.path.dirname(sys.argv[0]), '../perf_expectations.json') +CONFIG_JSON = os.path.join(os.path.dirname(sys.argv[0]), + '../chromium_perf_expectations.cfg') + class PerfExpectationsUnittest(unittest.TestCase): def testPerfExpectations(self): - perf_data = LoadData() - # Test data is dictionary. - perf_data = LoadData() + perf_data = LoadJsonFile(PERF_EXPECTATIONS) if not isinstance(perf_data, dict): raise Exception('perf expectations is not a dict') @@ -143,5 +145,15 @@ class PerfExpectationsUnittest(unittest.TestCase): msg = "perf expectations keys in bad format, expected a/b/c/d" raise Exception("%s: %s" % (msg, bad_keys)) + def testConfigFile(self): + # Test that the config file can be parsed as JSON. + config = LoadJsonFile(CONFIG_JSON) + # Require the following keys. + if 'base_url' not in config: + raise Exception('base_url not specified in config file') + if 'perf_file' not in config: + raise Exception('perf_file not specified in config file') + + if __name__ == '__main__': unittest.main() |