Roll src/third_party/WebKit 06cb9e9:a978ee5 (svn 202558:202559)
[chromium-blink-merge.git] / testing / scripts / telemetry_perf_unittests.py
blob063e818b763e6a93e4e0afbe49ec1635651ba52e
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 import json
7 import os
8 import sys
11 import common
14 def main_run(args):
15 filter_tests = []
16 if args.filter_file:
17 filter_tests = json.load(args.filter_file)
19 test_args = ['--retry-limit', '3']
20 if 'android' == args.properties.get('target_platform'):
21 test_args += [
22 '--browser', 'android-chromium',
23 '--device', 'android',
24 '--android-blacklist-file',
25 os.path.join(args.paths['checkout'], 'out', 'bad_devices.json'),
27 else:
28 test_args += ['--browser', args.build_config_fs.lower()]
30 with common.temporary_file() as tempfile_path:
31 test_args += ['--write-full-results-to', tempfile_path]
32 rc = common.run_runtest(args, [
33 '--test-type', 'telemetry_perf_unittests',
34 '--run-python-script',
35 os.path.join(common.SRC_DIR, 'tools', 'perf', 'run_tests')
36 ] + test_args + filter_tests)
38 with open(tempfile_path) as f:
39 results = json.load(f)
41 parsed_results = common.parse_common_test_results(results, test_separator='.')
42 failures = parsed_results['unexpected_failures']
44 json.dump({
45 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
46 ((rc == 0) or failures)),
47 'failures': failures.keys(),
48 }, args.output)
50 return rc
53 def main_compile_targets(args):
54 if 'android' == args.properties.get('target_platform'):
55 json.dump(['chrome_public_apk'], args.output)
56 else:
57 json.dump(['chrome'], args.output)
60 if __name__ == '__main__':
61 funcs = {
62 'run': main_run,
63 'compile_targets': main_compile_targets,
65 sys.exit(common.run_script(sys.argv[1:], funcs))