Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1239)

Side by Side Diff: testing/scripts/run_telemetry_benchmark_as_googletest.py

Issue 2366673002: Updating benchmark script to only write chartjson when flag present. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 isolate bundled Telemetry benchmark. 6 """Runs an isolate bundled Telemetry benchmark.
7 7
8 This script attempts to emulate the contract of gtest-style tests 8 This script attempts to emulate the contract of gtest-style tests
9 invoked via recipes. The main contract is that the caller passes the 9 invoked via recipes. The main contract is that the caller passes the
10 argument: 10 argument:
(...skipping 26 matching lines...) Expand all
37 # Importing it and using its get_sandbox_env breaks test runs on Linux 37 # Importing it and using its get_sandbox_env breaks test runs on Linux
38 # (it seems to unset DISPLAY). 38 # (it seems to unset DISPLAY).
39 CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX' 39 CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX'
40 CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox' 40 CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox'
41 41
42 def main(): 42 def main():
43 parser = argparse.ArgumentParser() 43 parser = argparse.ArgumentParser()
44 parser.add_argument( 44 parser.add_argument(
45 '--isolated-script-test-output', type=argparse.FileType('w'), 45 '--isolated-script-test-output', type=argparse.FileType('w'),
46 required=True) 46 required=True)
47 parser.add_argument( 47 # Only create the chartjson directory if this test is producing chartjson
48 '--isolated-script-test-chartjson-output', type=argparse.FileType('w'), 48 # results. Otherwise, remove from the argument list.
49 required=False) 49 writing_chartjson_results = '--output-format=chartjson' in sys.argv
50 if writing_chartjson_results:
51 parser.add_argument(
52 '--isolated-script-test-chartjson-output', type=argparse.FileType('w'),
53 required=False)
54 else:
55 for arg in sys.argv:
56 if 'isolated-script-test-chartjson-output' in arg:
57 sys.argv.remove(arg)
58 break
Ken Russell (switch to Gerrit) 2016/09/22 20:31:48 Instead of this somewhat contorted code, could you
eyaich1 2016/09/23 13:52:38 Done.
50 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true') 59 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true')
51 args, rest_args = parser.parse_known_args() 60 args, rest_args = parser.parse_known_args()
52 xvfb_proc = None 61 xvfb_proc = None
53 openbox_proc = None 62 openbox_proc = None
54 xcompmgr_proc = None 63 xcompmgr_proc = None
55 env = os.environ.copy() 64 env = os.environ.copy()
56 # Assume we want to set up the sandbox environment variables all the 65 # Assume we want to set up the sandbox environment variables all the
57 # time; doing so is harmless on non-Linux platforms and is needed 66 # time; doing so is harmless on non-Linux platforms and is needed
58 # all the time on Linux. 67 # all the time on Linux.
59 env[CHROME_SANDBOX_ENV] = CHROME_SANDBOX_PATH 68 env[CHROME_SANDBOX_ENV] = CHROME_SANDBOX_PATH
60 if args.xvfb and xvfb.should_start_xvfb(env): 69 if args.xvfb and xvfb.should_start_xvfb(env):
61 xvfb_proc, openbox_proc, xcompmgr_proc = xvfb.start_xvfb(env=env, 70 xvfb_proc, openbox_proc, xcompmgr_proc = xvfb.start_xvfb(env=env,
62 build_dir='.') 71 build_dir='.')
63 assert xvfb_proc and openbox_proc and xcompmgr_proc, 'Failed to start xvfb' 72 assert xvfb_proc and openbox_proc and xcompmgr_proc, 'Failed to start xvfb'
64 try: 73 try:
65 tempfile_dir = tempfile.mkdtemp('telemetry') 74 tempfile_dir = tempfile.mkdtemp('telemetry')
66 valid = True 75 valid = True
67 failures = [] 76 failures = []
68 chartjson = (args.isolated_script_test_chartjson_output is not None and 77 chartjson = (writing_chartjson_results
69 '--output-format=chartjson' in rest_args) 78 and args.isolated_script_test_chartjson_output is not None)
70 chartresults = None 79 chartresults = None
71 try: 80 try:
72 rc = common.run_command([sys.executable] + rest_args + [ 81 rc = common.run_command([sys.executable] + rest_args + [
73 '--output-dir', tempfile_dir, 82 '--output-dir', tempfile_dir,
74 '--output-format=json' 83 '--output-format=json'
75 ], env=env) 84 ], env=env)
76 tempfile_name = os.path.join(tempfile_dir, 'results.json') 85 tempfile_name = os.path.join(tempfile_dir, 'results.json')
77 with open(tempfile_name) as f: 86 with open(tempfile_name) as f:
78 results = json.load(f) 87 results = json.load(f)
79 for value in results['per_page_values']: 88 for value in results['per_page_values']:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 130
122 if __name__ == '__main__': 131 if __name__ == '__main__':
123 # Conform minimally to the protocol defined by ScriptTest. 132 # Conform minimally to the protocol defined by ScriptTest.
124 if 'compile_targets' in sys.argv: 133 if 'compile_targets' in sys.argv:
125 funcs = { 134 funcs = {
126 'run': None, 135 'run': None,
127 'compile_targets': main_compile_targets, 136 'compile_targets': main_compile_targets,
128 } 137 }
129 sys.exit(common.run_script(sys.argv[1:], funcs)) 138 sys.exit(common.run_script(sys.argv[1:], funcs))
130 sys.exit(main()) 139 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698