| 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 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 15 matching lines...) Expand all Loading... |
| 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 # Add src/testing/ into sys.path for importing xvfb. | 32 # Add src/testing/ into sys.path for importing xvfb. |
| 33 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 33 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 34 import xvfb | 34 import xvfb |
| 35 | 35 |
| 36 # 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 |
| 38 # (it seems to unset DISPLAY). |
| 39 CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX' |
| 40 CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox' |
| 36 | 41 |
| 37 def main(): | 42 def main(): |
| 38 parser = argparse.ArgumentParser() | 43 parser = argparse.ArgumentParser() |
| 39 parser.add_argument( | 44 parser.add_argument( |
| 40 '--isolated-script-test-output', type=argparse.FileType('w'), | 45 '--isolated-script-test-output', type=argparse.FileType('w'), |
| 41 required=True) | 46 required=True) |
| 42 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true') | 47 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true') |
| 43 args, rest_args = parser.parse_known_args() | 48 args, rest_args = parser.parse_known_args() |
| 44 xvfb_proc = None | 49 xvfb_proc = None |
| 45 openbox_proc = None | 50 openbox_proc = None |
| 46 env = os.environ.copy() | 51 env = os.environ.copy() |
| 52 # Assume we want to set up the sandbox environment variables all the |
| 53 # time; doing so is harmless on non-Linux platforms and is needed |
| 54 # all the time on Linux. |
| 55 env[CHROME_SANDBOX_ENV] = CHROME_SANDBOX_PATH |
| 47 if args.xvfb and xvfb.should_start_xvfb(env): | 56 if args.xvfb and xvfb.should_start_xvfb(env): |
| 48 xvfb_proc, openbox_proc = xvfb.start_xvfb(env=env, build_dir='.') | 57 xvfb_proc, openbox_proc = xvfb.start_xvfb(env=env, build_dir='.') |
| 49 assert xvfb_proc and openbox_proc, 'Failed to start xvfb' | 58 assert xvfb_proc and openbox_proc, 'Failed to start xvfb' |
| 50 try: | 59 try: |
| 51 tempfile_dir = tempfile.mkdtemp('telemetry') | 60 tempfile_dir = tempfile.mkdtemp('telemetry') |
| 52 valid = True | 61 valid = True |
| 53 failures = [] | 62 failures = [] |
| 54 try: | 63 try: |
| 55 rc = common.run_command([sys.executable] + rest_args + [ | 64 rc = common.run_command([sys.executable] + rest_args + [ |
| 56 '--output-dir', tempfile_dir, | 65 '--output-dir', tempfile_dir, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 99 |
| 91 if __name__ == '__main__': | 100 if __name__ == '__main__': |
| 92 # Conform minimally to the protocol defined by ScriptTest. | 101 # Conform minimally to the protocol defined by ScriptTest. |
| 93 if 'compile_targets' in sys.argv: | 102 if 'compile_targets' in sys.argv: |
| 94 funcs = { | 103 funcs = { |
| 95 'run': None, | 104 'run': None, |
| 96 'compile_targets': main_compile_targets, | 105 'compile_targets': main_compile_targets, |
| 97 } | 106 } |
| 98 sys.exit(common.run_script(sys.argv[1:], funcs)) | 107 sys.exit(common.run_script(sys.argv[1:], funcs)) |
| 99 sys.exit(main()) | 108 sys.exit(main()) |
| OLD | NEW |