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