| 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 | |
| 1060 def _MainParse(options, _args): | 1032 def _MainParse(options, _args): |
| 1061 """Run input through annotated test parser. | 1033 """Run input through annotated test parser. |
| 1062 | 1034 |
| 1063 This doesn't execute a test, but reads test input from a file and runs it | 1035 This doesn't execute a test, but reads test input from a file and runs it |
| 1064 through the specified annotation parser (aka log processor). | 1036 through the specified annotation parser (aka log processor). |
| 1065 """ | 1037 """ |
| 1066 if not options.annotate: | 1038 if not options.annotate: |
| 1067 raise chromium_utils.MissingArgument('--parse-input doesn\'t make sense ' | 1039 raise chromium_utils.MissingArgument('--parse-input doesn\'t make sense ' |
| 1068 'without --annotate.') | 1040 'without --annotate.') |
| 1069 | 1041 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 test_exe_path=test_exe_path, | 1127 test_exe_path=test_exe_path, |
| 1156 document_root=options.document_root) | 1128 document_root=options.document_root) |
| 1157 | 1129 |
| 1158 if _UsingGtestJson(options): | 1130 if _UsingGtestJson(options): |
| 1159 json_file_name = log_processor.PrepareJSONFile( | 1131 json_file_name = log_processor.PrepareJSONFile( |
| 1160 options.test_launcher_summary_output) | 1132 options.test_launcher_summary_output) |
| 1161 command.append('--test-launcher-summary-output=%s' % json_file_name) | 1133 command.append('--test-launcher-summary-output=%s' % json_file_name) |
| 1162 | 1134 |
| 1163 pipes = [] | 1135 pipes = [] |
| 1164 if options.enable_asan: | 1136 if options.enable_asan: |
| 1165 symbolize_command = _GetSanitizerSymbolizeCommand() | 1137 symbolize = os.path.abspath(os.path.join('src', 'tools', 'valgrind', |
| 1166 pipes = [symbolize_command, ['c++filt']] | 1138 'asan', 'asan_symbolize.py')) |
| 1139 pipes = [[sys.executable, symbolize], ['c++filt']] |
| 1167 | 1140 |
| 1168 command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, | 1141 command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, |
| 1169 command) | 1142 command) |
| 1170 result = _RunGTestCommand(command, extra_env, pipes=pipes, | 1143 result = _RunGTestCommand(command, extra_env, pipes=pipes, |
| 1171 log_processor=log_processor) | 1144 log_processor=log_processor) |
| 1172 finally: | 1145 finally: |
| 1173 if http_server: | 1146 if http_server: |
| 1174 http_server.StopServer() | 1147 http_server.StopServer() |
| 1175 if _UsingGtestJson(options): | 1148 if _UsingGtestJson(options): |
| 1176 _UploadGtestJsonSummary(json_file_name, | 1149 _UploadGtestJsonSummary(json_file_name, |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 'True'), | 1399 'True'), |
| 1427 server_dir=special_xvfb_dir) | 1400 server_dir=special_xvfb_dir) |
| 1428 | 1401 |
| 1429 if _UsingGtestJson(options): | 1402 if _UsingGtestJson(options): |
| 1430 json_file_name = log_processor.PrepareJSONFile( | 1403 json_file_name = log_processor.PrepareJSONFile( |
| 1431 options.test_launcher_summary_output) | 1404 options.test_launcher_summary_output) |
| 1432 command.append('--test-launcher-summary-output=%s' % json_file_name) | 1405 command.append('--test-launcher-summary-output=%s' % json_file_name) |
| 1433 | 1406 |
| 1434 pipes = [] | 1407 pipes = [] |
| 1435 # See the comment in main() regarding offline symbolization. | 1408 # See the comment in main() regarding offline symbolization. |
| 1436 if options.use_symbolization_script: | 1409 if (options.enable_asan or options.enable_msan) and not options.enable_lsan: |
| 1437 symbolize_command = _GetSanitizerSymbolizeCommand( | 1410 symbolize = os.path.abspath(os.path.join('src', 'tools', 'valgrind', |
| 1438 strip_path_prefix=options.strip_path_prefix) | 1411 'asan', 'asan_symbolize.py')) |
| 1439 pipes = [symbolize_command] | 1412 asan_symbolize = [sys.executable, symbolize] |
| 1413 if options.strip_path_prefix: |
| 1414 asan_symbolize.append(options.strip_path_prefix) |
| 1415 pipes = [asan_symbolize] |
| 1440 | 1416 |
| 1441 command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, | 1417 command = _GenerateRunIsolatedCommand(build_dir, test_exe_path, options, |
| 1442 command) | 1418 command) |
| 1443 result = _RunGTestCommand(command, extra_env, pipes=pipes, | 1419 result = _RunGTestCommand(command, extra_env, pipes=pipes, |
| 1444 log_processor=log_processor) | 1420 log_processor=log_processor) |
| 1445 finally: | 1421 finally: |
| 1446 if http_server: | 1422 if http_server: |
| 1447 http_server.StopServer() | 1423 http_server.StopServer() |
| 1448 if start_xvfb: | 1424 if start_xvfb: |
| 1449 xvfb.StopVirtualX(slave_name) | 1425 xvfb.StopVirtualX(slave_name) |
| 1450 if _UsingGtestJson(options): | 1426 if _UsingGtestJson(options): |
| 1451 if options.use_symbolization_script: | |
| 1452 _SymbolizeSnippetsInJSON(options, json_file_name) | |
| 1453 if json_file_name: | 1427 if json_file_name: |
| 1454 _UploadGtestJsonSummary(json_file_name, | 1428 _UploadGtestJsonSummary(json_file_name, |
| 1455 options.build_properties, | 1429 options.build_properties, |
| 1456 test_exe) | 1430 test_exe) |
| 1457 log_processor.ProcessJSONFile(options.build_dir) | 1431 log_processor.ProcessJSONFile(options.build_dir) |
| 1458 | 1432 |
| 1459 if options.generate_json_file: | 1433 if options.generate_json_file: |
| 1460 if not _GenerateJSONForTestResults(options, log_processor): | 1434 if not _GenerateJSONForTestResults(options, log_processor): |
| 1461 return 1 | 1435 return 1 |
| 1462 | 1436 |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1982 disable_sandbox_flag = '--additional-drt-flag=%s' % disable_sandbox_flag | 1956 disable_sandbox_flag = '--additional-drt-flag=%s' % disable_sandbox_flag |
| 1983 | 1957 |
| 1984 # Symbolization of sanitizer reports. | 1958 # Symbolization of sanitizer reports. |
| 1985 if options.enable_tsan or options.enable_lsan: | 1959 if options.enable_tsan or options.enable_lsan: |
| 1986 # TSan and LSan are not sandbox-compatible, so we can use online | 1960 # TSan and LSan are not sandbox-compatible, so we can use online |
| 1987 # symbolization. In fact, they need symbolization to be able to apply | 1961 # symbolization. In fact, they need symbolization to be able to apply |
| 1988 # suppressions. | 1962 # suppressions. |
| 1989 symbolization_options = ['symbolize=1', | 1963 symbolization_options = ['symbolize=1', |
| 1990 'external_symbolizer_path=%s' % symbolizer_path, | 1964 'external_symbolizer_path=%s' % symbolizer_path, |
| 1991 'strip_path_prefix=%s' % strip_path_prefix] | 1965 'strip_path_prefix=%s' % strip_path_prefix] |
| 1992 options.use_symbolization_script = False | |
| 1993 else: | 1966 else: |
| 1994 # ASan and MSan use a script for offline symbolization. | 1967 # ASan and MSan use a script for offline symbolization. |
| 1995 # Important note: when running ASan or MSan with leak detection enabled, | 1968 # Important note: when running ASan or MSan with leak detection enabled, |
| 1996 # we must use the LSan symbolization options above. | 1969 # we must use the LSan symbolization options above. |
| 1997 symbolization_options = ['symbolize=0'] | 1970 symbolization_options = ['symbolize=0'] |
| 1998 # Set the path to llvm-symbolizer to be used by asan_symbolize.py | 1971 # Set the path to llvm-symbolizer to be used by asan_symbolize.py |
| 1999 extra_env['LLVM_SYMBOLIZER_PATH'] = symbolizer_path | 1972 extra_env['LLVM_SYMBOLIZER_PATH'] = symbolizer_path |
| 2000 options.use_symbolization_script = True | |
| 2001 | 1973 |
| 2002 def AddToExistingEnv(env_dict, key, options_list): | 1974 def AddToExistingEnv(env_dict, key, options_list): |
| 2003 # Adds a key to the supplied environment dictionary but appends it to | 1975 # Adds a key to the supplied environment dictionary but appends it to |
| 2004 # existing environment variables if it already contains values. | 1976 # existing environment variables if it already contains values. |
| 2005 assert type(env_dict) is dict | 1977 assert type(env_dict) is dict |
| 2006 assert type(options_list) is list | 1978 assert type(options_list) is list |
| 2007 env_dict[key] = ' '.join(filter(bool, [os.environ.get(key)]+options_list)) | 1979 env_dict[key] = ' '.join(filter(bool, [os.environ.get(key)]+options_list)) |
| 2008 | 1980 |
| 2009 # ThreadSanitizer | 1981 # ThreadSanitizer |
| 2010 if options.enable_tsan: | 1982 if options.enable_tsan: |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 finally: | 2092 finally: |
| 2121 if did_launch_dbus: | 2093 if did_launch_dbus: |
| 2122 # It looks like the command line argument --exit-with-session | 2094 # It looks like the command line argument --exit-with-session |
| 2123 # isn't working to clean up the spawned dbus-daemon. Kill it | 2095 # isn't working to clean up the spawned dbus-daemon. Kill it |
| 2124 # manually. | 2096 # manually. |
| 2125 _ShutdownDBus() | 2097 _ShutdownDBus() |
| 2126 | 2098 |
| 2127 | 2099 |
| 2128 if '__main__' == __name__: | 2100 if '__main__' == __name__: |
| 2129 sys.exit(main()) | 2101 sys.exit(main()) |
| OLD | NEW |