OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Runs an isolated non-Telemetry perf test . | 6 """Runs an isolated non-Telemetry perf test . |
7 | 7 |
8 The main contract is that the caller passes the arguments: | 8 The main contract is that the caller passes the arguments: |
9 | 9 |
10 --isolated-script-test-output=[FILENAME] | 10 --isolated-script-test-output=[FILENAME] |
(...skipping 11 matching lines...) Expand all Loading... | |
22 import argparse | 22 import argparse |
23 import json | 23 import json |
24 import os | 24 import os |
25 import shutil | 25 import shutil |
26 import sys | 26 import sys |
27 import tempfile | 27 import tempfile |
28 import traceback | 28 import traceback |
29 | 29 |
30 import common | 30 import common |
31 | 31 |
32 | |
33 def GetChromiumSrcDir(): | |
34 return os.path.abspath( | |
35 os.path.join(os.path.abspath(__file__), '..', '..', '..')) | |
36 | |
37 def GetPerfDir(): | |
38 return os.path.join(GetChromiumSrcDir(), 'tools', 'perf') | |
39 # Add src/tools/perf wheree generate_legacy_perf_dashboard_json.py lives | |
Ken Russell (switch to Gerrit)
2016/11/04 15:16:16
typo: wheree
eyaich1
2016/11/04 17:33:02
Done.
| |
40 sys.path.append(GetPerfDir()) | |
41 | |
42 import generate_legacy_perf_dashboard_json | |
43 | |
32 # Add src/testing/ into sys.path for importing xvfb. | 44 # Add src/testing/ into sys.path for importing xvfb. |
33 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 45 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
34 import xvfb | 46 import xvfb |
35 | 47 |
36 # Unfortunately we need to copy these variables from ../test_env.py. | 48 # Unfortunately we need to copy these variables from ../test_env.py. |
37 # Importing it and using its get_sandbox_env breaks test runs on Linux | 49 # Importing it and using its get_sandbox_env breaks test runs on Linux |
38 # (it seems to unset DISPLAY). | 50 # (it seems to unset DISPLAY). |
39 CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX' | 51 CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX' |
40 CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox' | 52 CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox' |
41 | 53 |
(...skipping 29 matching lines...) Expand all Loading... | |
71 | 83 |
72 try: | 84 try: |
73 valid = True | 85 valid = True |
74 rc = 0 | 86 rc = 0 |
75 try: | 87 try: |
76 executable = rest_args[0] | 88 executable = rest_args[0] |
77 if IsWindows(): | 89 if IsWindows(): |
78 executable = '.\%s.exe' % executable | 90 executable = '.\%s.exe' % executable |
79 else: | 91 else: |
80 executable = './%s' % executable | 92 executable = './%s' % executable |
93 with common.temporary_file() as tempfile_path: | |
94 valid = (common.run_command_with_output([executable], | |
95 env=env, stdoutfile=tempfile_path) == 0) | |
eakuefner
2016/11/04 16:58:56
style nit: indent +4 spaces instead of +2.
eyaich1
2016/11/04 17:33:02
Done.
| |
81 | 96 |
82 rc = common.run_command_with_output([executable] + [ | 97 # Now get the correct json format from the stdout to write to the |
83 '--write-abbreviated-json-results-to', args.isolated_script_test_output, | 98 # perf results file |
84 ], env=env, stdoutfile=args.isolated_script_test_chartjson_output) | 99 results_processor = \ |
eakuefner
2016/11/04 16:58:56
style nit: no backslash line continuations in pyth
eyaich1
2016/11/04 17:33:02
Done.
| |
85 | 100 generate_legacy_perf_dashboard_json.LegacyResultsProcessor() |
86 # Now get the correct json format from the stdout to write to the | 101 charts = results_processor.GenerateJsonResults(tempfile_path) |
87 # perf results file | 102 # Write the returned encoded json to a the charts output file |
103 with open(args.isolated_script_test_chartjson_output, 'w') as f: | |
104 f.write(charts) | |
88 except Exception: | 105 except Exception: |
89 traceback.print_exc() | 106 traceback.print_exc() |
90 valid = False | 107 valid = False |
91 | 108 |
92 if not valid: | 109 failures = [] if valid else ['(entire test suite)'] |
93 failures = ['(entire test suite)'] | 110 with open(args.isolated_script_test_output, 'w') as fp: |
94 with open(args.isolated_script_test_output, 'w') as fp: | 111 json.dump({ |
95 json.dump({ | 112 'valid': valid, |
96 'valid': valid, | 113 'failures': failures, |
97 'failures': failures, | 114 }, fp) |
98 }, fp) | |
99 | 115 |
100 return rc | 116 return rc |
101 | 117 |
102 finally: | 118 finally: |
103 xvfb.kill(xvfb_proc) | 119 xvfb.kill(xvfb_proc) |
104 xvfb.kill(openbox_proc) | 120 xvfb.kill(openbox_proc) |
105 xvfb.kill(xcompmgr_proc) | 121 xvfb.kill(xcompmgr_proc) |
106 | 122 |
107 | 123 |
108 # This is not really a "script test" so does not need to manually add | 124 # This is not really a "script test" so does not need to manually add |
109 # any additional compile targets. | 125 # any additional compile targets. |
110 def main_compile_targets(args): | 126 def main_compile_targets(args): |
111 json.dump([], args.output) | 127 json.dump([], args.output) |
112 | 128 |
113 | 129 |
114 if __name__ == '__main__': | 130 if __name__ == '__main__': |
115 # Conform minimally to the protocol defined by ScriptTest. | 131 # Conform minimally to the protocol defined by ScriptTest. |
116 if 'compile_targets' in sys.argv: | 132 if 'compile_targets' in sys.argv: |
117 funcs = { | 133 funcs = { |
118 'run': None, | 134 'run': None, |
119 'compile_targets': main_compile_targets, | 135 'compile_targets': main_compile_targets, |
120 } | 136 } |
121 sys.exit(common.run_script(sys.argv[1:], funcs)) | 137 sys.exit(common.run_script(sys.argv[1:], funcs)) |
122 sys.exit(main()) | 138 sys.exit(main()) |
123 | 139 |
OLD | NEW |