summaryrefslogtreecommitdiffstats
path: root/tools/perf_expectations/tests
diff options
context:
space:
mode:
authorjvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-19 20:37:13 +0000
committerjvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-19 20:37:13 +0000
commitb0a39178d73b6592dcf24114e53947d070399bab (patch)
tree6040f2492ec4b1df365138d64fddcf392d0e2137 /tools/perf_expectations/tests
parent49e44ddbb8a44bf21bd75ec086f661f04682548d (diff)
downloadchromium_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/tests')
-rwxr-xr-xtools/perf_expectations/tests/perf_expectations_unittest.py34
1 files changed, 23 insertions, 11 deletions
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()