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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 # Assume we want to set up the sandbox environment variables all the | 75 # Assume we want to set up the sandbox environment variables all the |
76 # time; doing so is harmless on non-Linux platforms and is needed | 76 # time; doing so is harmless on non-Linux platforms and is needed |
77 # all the time on Linux. | 77 # all the time on Linux. |
78 env[CHROME_SANDBOX_ENV] = CHROME_SANDBOX_PATH | 78 env[CHROME_SANDBOX_ENV] = CHROME_SANDBOX_PATH |
79 if args.xvfb and xvfb.should_start_xvfb(env): | 79 if args.xvfb and xvfb.should_start_xvfb(env): |
80 xvfb_proc, openbox_proc, xcompmgr_proc = xvfb.start_xvfb(env=env, | 80 xvfb_proc, openbox_proc, xcompmgr_proc = xvfb.start_xvfb(env=env, |
81 build_dir='.') | 81 build_dir='.') |
82 assert xvfb_proc and openbox_proc and xcompmgr_proc, 'Failed to start xvfb' | 82 assert xvfb_proc and openbox_proc and xcompmgr_proc, 'Failed to start xvfb' |
83 | 83 |
84 try: | 84 try: |
85 valid = True | |
86 rc = 0 | 85 rc = 0 |
87 try: | 86 try: |
88 executable = rest_args[0] | 87 executable = rest_args[0] |
89 extra_flags = [] | 88 extra_flags = [] |
90 if len(rest_args) > 1: | 89 if len(rest_args) > 1: |
91 extra_flags = rest_args[1:] | 90 extra_flags = rest_args[1:] |
92 if IsWindows(): | 91 if IsWindows(): |
93 executable = '.\%s.exe' % executable | 92 executable = '.\%s.exe' % executable |
94 else: | 93 else: |
95 executable = './%s' % executable | 94 executable = './%s' % executable |
96 with common.temporary_file() as tempfile_path: | 95 with common.temporary_file() as tempfile_path: |
97 valid = (common.run_command_with_output([executable] + extra_flags, | 96 rc = common.run_command_with_output([executable] + extra_flags, |
98 env=env, stdoutfile=tempfile_path) == 0) | 97 env=env, stdoutfile=tempfile_path) |
99 | 98 |
100 # Now get the correct json format from the stdout to write to the | 99 # Now get the correct json format from the stdout to write to the |
101 # perf results file | 100 # perf results file |
102 results_processor = ( | 101 results_processor = ( |
103 generate_legacy_perf_dashboard_json.LegacyResultsProcessor()) | 102 generate_legacy_perf_dashboard_json.LegacyResultsProcessor()) |
104 charts = results_processor.GenerateJsonResults(tempfile_path) | 103 charts = results_processor.GenerateJsonResults(tempfile_path) |
105 # Write the returned encoded json to a the charts output file | 104 # Write the returned encoded json to a the charts output file |
106 with open(args.isolated_script_test_chartjson_output, 'w') as f: | 105 with open(args.isolated_script_test_chartjson_output, 'w') as f: |
107 f.write(charts) | 106 f.write(charts) |
108 except Exception: | 107 except Exception: |
109 traceback.print_exc() | 108 traceback.print_exc() |
110 valid = False | 109 rc = 1 |
111 | 110 |
| 111 valid = (rc == 0) |
112 failures = [] if valid else ['(entire test suite)'] | 112 failures = [] if valid else ['(entire test suite)'] |
113 with open(args.isolated_script_test_output, 'w') as fp: | 113 with open(args.isolated_script_test_output, 'w') as fp: |
114 json.dump({ | 114 json.dump({ |
115 'valid': valid, | 115 'valid': valid, |
116 'failures': failures, | 116 'failures': failures, |
117 }, fp) | 117 }, fp) |
118 | 118 |
119 return rc | 119 return rc |
120 | 120 |
121 finally: | 121 finally: |
(...skipping 11 matching lines...) Expand all Loading... |
133 if __name__ == '__main__': | 133 if __name__ == '__main__': |
134 # Conform minimally to the protocol defined by ScriptTest. | 134 # Conform minimally to the protocol defined by ScriptTest. |
135 if 'compile_targets' in sys.argv: | 135 if 'compile_targets' in sys.argv: |
136 funcs = { | 136 funcs = { |
137 'run': None, | 137 'run': None, |
138 'compile_targets': main_compile_targets, | 138 'compile_targets': main_compile_targets, |
139 } | 139 } |
140 sys.exit(common.run_script(sys.argv[1:], funcs)) | 140 sys.exit(common.run_script(sys.argv[1:], funcs)) |
141 sys.exit(main()) | 141 sys.exit(main()) |
142 | 142 |
OLD | NEW |