diff options
author | cmtice <cmtice@google.com> | 2014-05-07 13:22:37 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-05-08 01:20:38 +0000 |
commit | 2fca8ce27632ebce63627b5a51e9749e68bcf8b9 (patch) | |
tree | 1b1721fc6357a07861e097257767d3eec0cf66fa /crosperf/benchmark_unittest.py | |
parent | 6ffbb92f0913f990b6a5c7ef706aee9bfb4faa9e (diff) | |
download | toolchain-utils-2fca8ce27632ebce63627b5a51e9749e68bcf8b9.tar.gz |
Add 3 unittests, for test_flag.py, config.py and benchmark.py
BUG=None
TEST=Ran unittests.
Change-Id: I2c421f8322e58173932656da9ae7a5af1bf3febd
Reviewed-on: https://chrome-internal-review.googlesource.com/162886
Reviewed-by: Yunlian Jiang <yunlian@google.com>
Commit-Queue: Caroline Tice <cmtice@google.com>
Tested-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'crosperf/benchmark_unittest.py')
-rw-r--r-- | crosperf/benchmark_unittest.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/crosperf/benchmark_unittest.py b/crosperf/benchmark_unittest.py new file mode 100644 index 00000000..f7ab1895 --- /dev/null +++ b/crosperf/benchmark_unittest.py @@ -0,0 +1,56 @@ +#!/usr/bin/python +# +# Copyright 2014 Google Inc. All Rights Reserved + +import inspect +from benchmark import Benchmark + +import unittest + +class BenchmarkTestCase(unittest.TestCase): + + def test_benchmark(self): + # Test creating a benchmark with all the fields filled out. + b1 = Benchmark("b1_test", # name + "octane", # test_name + "", # test_args + 3, # iterations + False, # rm_chroot_tmp + "record -e cycles", # perf_args + "telemetry_Crosperf", # suite + True) # show_all_results + + # Test creating a benchmark field with default fields left out. + b2 = Benchmark("b2_test", # name + "octane", # test_name + "", # test_args + 3, # iterations + False, # rm_chroot_tmp + "record -e cycles") # perf_args + self.assertEqual(b2.suite, "") + self.assertFalse(b2.show_all_results) + + # Test explicitly creating 'suite=Telemetry' and 'show_all_results=False" + # and see what happens. + b3 = Benchmark("b3_test", # name + "octane", # test_name + "", # test_args + 3, # iterations + False, # rm_chroot_tmp + "record -e cycles", # perf_args + "telemetry", # suite + False) # show_all_results + self.assertTrue(b3.show_all_results) + + # Check to see if the args to Benchmark have changed since the last time + # this test was updated. + args_list = ['self', 'name', 'test_name', 'test_args', 'iterations', + 'rm_chroot_tmp', 'perf_args', 'suite', 'show_all_results'] + arg_spec = inspect.getargspec(Benchmark.__init__) + self.assertEqual(len(arg_spec.args), len(args_list)) + for arg in args_list: + self.assertIn (arg, arg_spec.args) + + +if __name__ == '__main__': + unittest.main() |