kbr | 814c9e9 | 2015-07-06 23:38:34 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2015 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. |
| 5 | |
| 6 | import json |
| 7 | import os |
| 8 | import sys |
| 9 | |
| 10 | |
| 11 | import common |
| 12 | |
| 13 | |
| 14 | def main_run(args): |
| 15 | filter_tests = [] |
| 16 | if args.filter_file: |
| 17 | filter_tests = json.load(args.filter_file) |
| 18 | |
| 19 | with common.temporary_file() as tempfile_path: |
| 20 | rc = common.run_runtest(args, [ |
| 21 | '--test-type', 'telemetry_gpu_unittests', |
| 22 | '--run-python-script', |
| 23 | os.path.join(common.SRC_DIR, |
| 24 | 'content', 'test', 'gpu', 'run_unittests.py'), |
| 25 | '--retry-limit', '3', |
| 26 | '--write-full-results-to', tempfile_path, |
| 27 | ] + filter_tests) |
| 28 | |
| 29 | with open(tempfile_path) as f: |
| 30 | results = json.load(f) |
| 31 | |
| 32 | parsed_results = common.parse_common_test_results(results, test_separator='.') |
| 33 | failures = parsed_results['unexpected_failures'] |
| 34 | |
| 35 | json.dump({ |
| 36 | 'valid': bool(rc <= common.MAX_FAILURES_EXIT_STATUS and |
| 37 | ((rc == 0) or failures)), |
| 38 | 'failures': failures.keys(), |
| 39 | }, args.output) |
| 40 | |
| 41 | return rc |
| 42 | |
| 43 | |
| 44 | def main_compile_targets(args): |
| 45 | json.dump([], args.output) |
| 46 | |
| 47 | |
| 48 | if __name__ == '__main__': |
| 49 | funcs = { |
| 50 | 'run': main_run, |
| 51 | 'compile_targets': main_compile_targets, |
| 52 | } |
| 53 | sys.exit(common.run_script(sys.argv[1:], funcs)) |