Automated Commit: Committing new LKGM version 6953.0.0 for chromeos.
[chromium-blink-merge.git] / testing / scripts / telemetry_unittests.py
blob50af0c08bf6fdd3ae80b2c5134d61d5ab635e7ce
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 with common.temporary_file() as tempfile_path:
20 rc = common.run_runtest(args, [
21 '--annotate', 'gtest',
22 '--test-type', 'telemetry_unittests',
23 '--run-python-script',
24 os.path.join(common.SRC_DIR, 'tools', 'telemetry', 'run_tests'),
25 '--browser', args.build_config_fs.lower(),
26 '--retry-limit', '3',
27 '--write-full-results-to', tempfile_path,
28 ] + filter_tests)
30 with open(tempfile_path) as f:
31 results = json.load(f)
33 parsed_results = common.parse_common_test_results(results, test_separator='.')
34 failures = parsed_results['unexpected_failures']
36 json.dump({
37 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and
38 ((rc == 0) or failures)),
39 'failures': failures.keys(),
40 }, args.output)
42 return rc
45 def main_compile_targets(args):
46 json.dump(['chrome'], args.output)
49 if __name__ == '__main__':
50 funcs = {
51 'run': main_run,
52 'compile_targets': main_compile_targets,
54 sys.exit(common.run_script(sys.argv[1:], funcs))