1#!/usr/bin/env vpython3 2# Copyright 2017 The Chromium Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import argparse 7import json 8import os 9import sys 10 11import common 12 13sys.path.append( 14 os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) 15# //testing imports. 16import xvfb 17 18 19def main(argv): 20 parser = argparse.ArgumentParser() 21 parser.add_argument('--isolated-script-test-output', type=str, required=False) 22 parser.add_argument('--isolated-script-test-chartjson-output', 23 type=str, 24 required=False) 25 parser.add_argument('--isolated-script-test-perf-output', 26 type=str, 27 required=False) 28 parser.add_argument('--isolated-script-test-filter', type=str, required=False) 29 parser.add_argument('--platform', 30 type=str, 31 default=sys.platform, 32 required=False) 33 34 args = parser.parse_args(argv) 35 36 env = os.environ.copy() 37 38 additional_args = [] 39 if args.platform == 'win32': 40 exe = os.path.join('.', 'content_shell.exe') 41 elif args.platform == 'darwin': 42 exe = os.path.join('.', 'Content Shell.app', 'Contents', 'MacOS', 43 'Content Shell') 44 # The Content Shell binary does not directly link against 45 # the Content Shell Framework (it is loaded at runtime). Ensure that 46 # symbols are dumped for the Framework too. 47 additional_args = [ 48 '--additional-binary', 49 os.path.join('.', 'Content Shell.app', 'Contents', 'Frameworks', 50 'Content Shell Framework.framework', 'Versions', 'Current', 51 'Content Shell Framework') 52 ] 53 elif args.platform == 'android': 54 exe = os.path.join('.', 'lib.unstripped', 55 'libcontent_shell_content_view.so') 56 else: 57 exe = os.path.join('.', 'content_shell') 58 59 with common.temporary_file() as tempfile_path: 60 env['CHROME_HEADLESS'] = '1' 61 rc = xvfb.run_executable([ 62 sys.executable, 63 os.path.join(common.SRC_DIR, 'content', 'shell', 'tools', 64 'breakpad_integration_test.py'), 65 '--verbose', 66 '--build-dir', 67 '.', 68 '--binary', 69 exe, 70 '--json', 71 tempfile_path, 72 '--platform', 73 args.platform, 74 ] + additional_args, env) 75 76 with open(tempfile_path) as f: 77 failures = json.load(f) 78 79 if args.isolated_script_test_output: 80 with open(args.isolated_script_test_output, 'w') as fp: 81 common.record_local_script_results('content_shell_crash_test', fp, 82 failures, True) 83 84 return rc 85 86 87def main_compile_targets(args): 88 json.dump(['content_shell_crash_test'], args.output) 89 90 91if __name__ == '__main__': 92 # Conform minimally to the protocol defined by ScriptTest. 93 if 'compile_targets' in sys.argv: 94 funcs = { 95 'run': None, 96 'compile_targets': main_compile_targets, 97 } 98 sys.exit(common.run_script(sys.argv[1:], funcs)) 99 sys.exit(main(sys.argv[1:])) 100