Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / testing / scripts / telemetry_unittests.py
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.
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         '--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)
29
30     with open(tempfile_path) as f:
31       results = json.load(f)
32
33   parsed_results = common.parse_common_test_results(results, test_separator='.')
34   failures = parsed_results['unexpected_failures']
35
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)
41
42   return rc
43
44
45 def main_compile_targets(args):
46   json.dump(['chrome'], args.output)
47
48
49 if __name__ == '__main__':
50   funcs = {
51     'run': main_run,
52     'compile_targets': main_compile_targets,
53   }
54   sys.exit(common.run_script(sys.argv[1:], funcs))