OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """A tool used to run a Chrome test executable and process the output. | 6 """A tool used to run a Chrome test executable and process the output. |
7 | 7 |
8 This script is used by the buildbot slaves. It must be run from the outer | 8 This script is used by the buildbot slaves. It must be run from the outer |
9 build directory, e.g. chrome-release/build/. | 9 build directory, e.g. chrome-release/build/. |
10 | 10 |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 def _GetPerfID(options): | 1022 def _GetPerfID(options): |
1023 if options.perf_id: | 1023 if options.perf_id: |
1024 perf_id = options.perf_id | 1024 perf_id = options.perf_id |
1025 else: | 1025 else: |
1026 perf_id = options.factory_properties.get('perf_id') | 1026 perf_id = options.factory_properties.get('perf_id') |
1027 if options.factory_properties.get('add_perf_id_suffix'): | 1027 if options.factory_properties.get('add_perf_id_suffix'): |
1028 perf_id += options.build_properties.get('perf_id_suffix') | 1028 perf_id += options.build_properties.get('perf_id_suffix') |
1029 return perf_id | 1029 return perf_id |
1030 | 1030 |
1031 | 1031 |
| 1032 def _GetSanitizerSymbolizeCommand(strip_path_prefix=None, json_file_name=None): |
| 1033 script_path = os.path.abspath(os.path.join('src', 'tools', 'valgrind', |
| 1034 'asan', 'asan_symbolize.py')) |
| 1035 command = [sys.executable, script_path] |
| 1036 if strip_path_prefix: |
| 1037 command.append(strip_path_prefix) |
| 1038 if json_file_name: |
| 1039 command.append('--test-summary-json-file=%s' % json_file_name) |
| 1040 return command |
| 1041 |
| 1042 |
| 1043 def _SymbolizeSnippetsInJSON(options, json_file_name): |
| 1044 if not json_file_name: |
| 1045 return |
| 1046 symbolize_command = _GetSanitizerSymbolizeCommand( |
| 1047 strip_path_prefix=options.strip_path_prefix, |
| 1048 json_file_name=json_file_name) |
| 1049 try: |
| 1050 p = subprocess.popen(symbolize_command, stderr=subprocess.PIPE) |
| 1051 (_, stderr) = p.communicate() |
| 1052 except OSError as e: |
| 1053 print 'Exception while symbolizing snippets: %s' % e |
| 1054 |
| 1055 if p.returncode != 0: |
| 1056 print "Error: failed to symbolize snippets in JSON:\n" |
| 1057 print stderr |
| 1058 |
| 1059 |
1032 def _MainParse(options, _args): | 1060 def _MainParse(options, _args): |
1033 """Run input through annotated test parser. | 1061 """Run input through annotated test parser. |
1034 | 1062 |
1035 This doesn't execute a test, but reads test input from a file and runs it | 1063 This doesn't execute a test, but reads test input from a file and runs it |
1036 through the specified annotation parser (aka log processor). | 1064 through the specified annotation parser (aka log processor). |
1037 """ | 1065 """ |
1038 if not options.annotate: | 1066 if not options.annotate: |
1039 raise chromium_utils.MissingArgument('--parse-input doesn\'t make sense ' | 1067 raise chromium_utils.MissingArgument('--parse-input doesn\'t make sense ' |
1040 'without --annotate.') | 1068 'without --annotate.') |
1041 | 1069 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 test_exe_path=test_exe_path, | 1155 test_exe_path=test_exe_path, |
1128 document_root=options.document_root) | 1156 document_root=options.document_root) |
1129 | 1157 |
1130 if _UsingGtestJson(options): | 1158 if _UsingGtestJson(options): |
1131 json_file_name = log_processor.PrepareJSONFile( | 1159 json_file_name = log_processor.PrepareJSONFile( |
1132 options.test_launcher_summary_output) | 1160 options.test_launcher_summary_output) |
1133 command.append('--test-launcher-summary-output=%s' % json_file_name) | 1161 command.append('--test-launcher-summary-output=%s' % json_file_name) |
1134 | 1162 |
1135 pipes = [] | 1163 pipes = [] |
1136 if options.enable_asan: | 1164 if options.enable_asan: |
1137 symbolize = os.path.abspath(os.path.join('src', 'tools', 'valgrind', | 1165 symbolize_command = _GetSanitizerSymbolizeCommand() |
1138 'asan', 'asan_symbolize.py')) | 1166 pipes = [symbolize_command, ['c++filt']] |
1139 pipes = [[sys.executable, symbolize], ['c++filt']] | |
1140 | 1167 |
1141 command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, | 1168 command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, |
1142 command) | 1169 command) |
1143 result = _RunGTestCommand(command, extra_env, pipes=pipes, | 1170 result = _RunGTestCommand(command, extra_env, pipes=pipes, |
1144 log_processor=log_processor) | 1171 log_processor=log_processor) |
1145 finally: | 1172 finally: |
1146 if http_server: | 1173 if http_server: |
1147 http_server.StopServer() | 1174 http_server.StopServer() |
1148 if _UsingGtestJson(options): | 1175 if _UsingGtestJson(options): |
1149 _UploadGtestJsonSummary(json_file_name, | 1176 _UploadGtestJsonSummary(json_file_name, |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 'True'), | 1426 'True'), |
1400 server_dir=special_xvfb_dir) | 1427 server_dir=special_xvfb_dir) |
1401 | 1428 |
1402 if _UsingGtestJson(options): | 1429 if _UsingGtestJson(options): |
1403 json_file_name = log_processor.PrepareJSONFile( | 1430 json_file_name = log_processor.PrepareJSONFile( |
1404 options.test_launcher_summary_output) | 1431 options.test_launcher_summary_output) |
1405 command.append('--test-launcher-summary-output=%s' % json_file_name) | 1432 command.append('--test-launcher-summary-output=%s' % json_file_name) |
1406 | 1433 |
1407 pipes = [] | 1434 pipes = [] |
1408 # See the comment in main() regarding offline symbolization. | 1435 # See the comment in main() regarding offline symbolization. |
1409 if (options.enable_asan or options.enable_msan) and not options.enable_lsan: | 1436 if options.use_symbolization_script: |
1410 symbolize = os.path.abspath(os.path.join('src', 'tools', 'valgrind', | 1437 symbolize_command = _GetSanitizerSymbolizeCommand( |
1411 'asan', 'asan_symbolize.py')) | 1438 strip_path_prefix=options.strip_path_prefix) |
1412 asan_symbolize = [sys.executable, symbolize] | 1439 pipes = [symbolize_command] |
1413 if options.strip_path_prefix: | |
1414 asan_symbolize.append(options.strip_path_prefix) | |
1415 pipes = [asan_symbolize] | |
1416 | 1440 |
1417 command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, | 1441 command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, |
1418 command) | 1442 command) |
1419 result = _RunGTestCommand(command, extra_env, pipes=pipes, | 1443 result = _RunGTestCommand(command, extra_env, pipes=pipes, |
1420 log_processor=log_processor) | 1444 log_processor=log_processor) |
1421 finally: | 1445 finally: |
1422 if http_server: | 1446 if http_server: |
1423 http_server.StopServer() | 1447 http_server.StopServer() |
1424 if start_xvfb: | 1448 if start_xvfb: |
1425 xvfb.StopVirtualX(slave_name) | 1449 xvfb.StopVirtualX(slave_name) |
1426 if _UsingGtestJson(options): | 1450 if _UsingGtestJson(options): |
| 1451 if options.use_symbolization_script: |
| 1452 _SymbolizeSnippetsInJSON(options, json_file_name) |
1427 if json_file_name: | 1453 if json_file_name: |
1428 _UploadGtestJsonSummary(json_file_name, | 1454 _UploadGtestJsonSummary(json_file_name, |
1429 options.build_properties, | 1455 options.build_properties, |
1430 test_exe) | 1456 test_exe) |
1431 log_processor.ProcessJSONFile(options.build_dir) | 1457 log_processor.ProcessJSONFile(options.build_dir) |
1432 | 1458 |
1433 if options.generate_json_file: | 1459 if options.generate_json_file: |
1434 if not _GenerateJSONForTestResults(options, log_processor): | 1460 if not _GenerateJSONForTestResults(options, log_processor): |
1435 return 1 | 1461 return 1 |
1436 | 1462 |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 # TODO(glider): remove the symbolizer path once | 1975 # TODO(glider): remove the symbolizer path once |
1950 # https://code.google.com/p/address-sanitizer/issues/detail?id=134 is fixed. | 1976 # https://code.google.com/p/address-sanitizer/issues/detail?id=134 is fixed. |
1951 symbolizer_path = os.path.abspath(os.path.join('src', 'third_party', | 1977 symbolizer_path = os.path.abspath(os.path.join('src', 'third_party', |
1952 'llvm-build', 'Release+Asserts', 'bin', 'llvm-symbolizer')) | 1978 'llvm-build', 'Release+Asserts', 'bin', 'llvm-symbolizer')) |
1953 strip_path_prefix = options.strip_path_prefix | 1979 strip_path_prefix = options.strip_path_prefix |
1954 disable_sandbox_flag = '--no-sandbox' | 1980 disable_sandbox_flag = '--no-sandbox' |
1955 if args and 'layout_test_wrapper' in args[0]: | 1981 if args and 'layout_test_wrapper' in args[0]: |
1956 disable_sandbox_flag = '--additional-drt-flag=%s' % disable_sandbox_flag | 1982 disable_sandbox_flag = '--additional-drt-flag=%s' % disable_sandbox_flag |
1957 | 1983 |
1958 # Symbolization of sanitizer reports. | 1984 # Symbolization of sanitizer reports. |
| 1985 options.use_symbolization_script = False |
1959 if options.enable_tsan or options.enable_lsan: | 1986 if options.enable_tsan or options.enable_lsan: |
1960 # TSan and LSan are not sandbox-compatible, so we can use online | 1987 # TSan and LSan are not sandbox-compatible, so we can use online |
1961 # symbolization. In fact, they need symbolization to be able to apply | 1988 # symbolization. In fact, they need symbolization to be able to apply |
1962 # suppressions. | 1989 # suppressions. |
1963 symbolization_options = ['symbolize=1', | 1990 symbolization_options = ['symbolize=1', |
1964 'external_symbolizer_path=%s' % symbolizer_path, | 1991 'external_symbolizer_path=%s' % symbolizer_path, |
1965 'strip_path_prefix=%s' % strip_path_prefix] | 1992 'strip_path_prefix=%s' % strip_path_prefix] |
1966 else: | 1993 elif options.enable_asan or options.enable_msan: |
1967 # ASan and MSan use a script for offline symbolization. | 1994 # ASan and MSan use a script for offline symbolization. |
1968 # Important note: when running ASan or MSan with leak detection enabled, | 1995 # Important note: when running ASan or MSan with leak detection enabled, |
1969 # we must use the LSan symbolization options above. | 1996 # we must use the LSan symbolization options above. |
1970 symbolization_options = ['symbolize=0'] | 1997 symbolization_options = ['symbolize=0'] |
1971 # Set the path to llvm-symbolizer to be used by asan_symbolize.py | 1998 # Set the path to llvm-symbolizer to be used by asan_symbolize.py |
1972 extra_env['LLVM_SYMBOLIZER_PATH'] = symbolizer_path | 1999 extra_env['LLVM_SYMBOLIZER_PATH'] = symbolizer_path |
| 2000 options.use_symbolization_script = True |
1973 | 2001 |
1974 def AddToExistingEnv(env_dict, key, options_list): | 2002 def AddToExistingEnv(env_dict, key, options_list): |
1975 # Adds a key to the supplied environment dictionary but appends it to | 2003 # Adds a key to the supplied environment dictionary but appends it to |
1976 # existing environment variables if it already contains values. | 2004 # existing environment variables if it already contains values. |
1977 assert type(env_dict) is dict | 2005 assert type(env_dict) is dict |
1978 assert type(options_list) is list | 2006 assert type(options_list) is list |
1979 env_dict[key] = ' '.join(filter(bool, [os.environ.get(key)]+options_list)) | 2007 env_dict[key] = ' '.join(filter(bool, [os.environ.get(key)]+options_list)) |
1980 | 2008 |
1981 # ThreadSanitizer | 2009 # ThreadSanitizer |
1982 if options.enable_tsan: | 2010 if options.enable_tsan: |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 finally: | 2120 finally: |
2093 if did_launch_dbus: | 2121 if did_launch_dbus: |
2094 # It looks like the command line argument --exit-with-session | 2122 # It looks like the command line argument --exit-with-session |
2095 # isn't working to clean up the spawned dbus-daemon. Kill it | 2123 # isn't working to clean up the spawned dbus-daemon. Kill it |
2096 # manually. | 2124 # manually. |
2097 _ShutdownDBus() | 2125 _ShutdownDBus() |
2098 | 2126 |
2099 | 2127 |
2100 if '__main__' == __name__: | 2128 if '__main__' == __name__: |
2101 sys.exit(main()) | 2129 sys.exit(main()) |
OLD | NEW |