Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
| 3 | import os |
| 4 | import platform |
| 5 | import re |
| 6 | import subprocess |
| 7 | import tempfile |
| 8 | |
| 9 | import lit.formats |
| 10 | import lit.util |
| 11 | |
| 12 | from lit.llvm import llvm_config |
| 13 | from lit.llvm.subst import ToolSubst |
| 14 | from lit.llvm.subst import FindTool |
| 15 | |
| 16 | # Configuration file for the 'lit' test runner. |
| 17 | |
| 18 | # name: The name of this test suite. |
| 19 | config.name = 'debuginfo-tests' |
| 20 | |
| 21 | # testFormat: The test format to use to interpret tests. |
| 22 | # |
| 23 | # For now we require '&&' between commands, until they get globally killed and |
| 24 | # the test runner updated. |
| 25 | config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) |
| 26 | |
| 27 | # suffixes: A list of file extensions to treat as test files. |
| 28 | config.suffixes = ['.c', '.cpp', '.m'] |
| 29 | |
| 30 | # excludes: A list of directories to exclude from the testsuite. The 'Inputs' |
| 31 | # subdirectories contain auxiliary inputs for various tests in their parent |
| 32 | # directories. |
| 33 | config.excludes = ['Inputs'] |
| 34 | |
| 35 | # test_source_root: The root path where tests are located. |
| 36 | config.test_source_root = os.path.join(config.debuginfo_tests_src_root) |
| 37 | |
| 38 | # test_exec_root: The root path where tests should be run. |
| 39 | config.test_exec_root = config.debuginfo_tests_obj_root |
| 40 | |
Reid Kleckner | 75d38f1 | 2019-05-28 23:03:33 +0000 | [diff] [blame^] | 41 | tools = [ |
| 42 | ToolSubst('%test_debuginfo', command=os.path.join( |
| 43 | config.debuginfo_tests_src_root, 'test_debuginfo.pl')), |
| 44 | ] |
| 45 | |
| 46 | def get_required_attr(config, attr_name): |
| 47 | attr_value = getattr(config, attr_name, None) |
| 48 | if attr_value == None: |
| 49 | lit_config.fatal( |
| 50 | "No attribute %r in test configuration! You may need to run " |
| 51 | "tests from your build directory or add this attribute " |
| 52 | "to lit.site.cfg " % attr_name) |
| 53 | return attr_value |
| 54 | |
| 55 | # If this is an MSVC environment, the tests at the root of the tree are |
| 56 | # unsupported. The local win_cdb test suite, however, is supported. |
| 57 | is_msvc = get_required_attr(config, "is_msvc") |
| 58 | if is_msvc: |
| 59 | # FIXME: We should add some llvm lit utility code to find the Windows SDK |
| 60 | # and set up the environment appopriately. |
| 61 | win_sdk = 'C:/Program Files (x86)/Windows Kits/10/' |
| 62 | arch = 'x64' |
| 63 | config.unsupported = True |
| 64 | llvm_config.with_system_environment(['LIB', 'LIBPATH', 'INCLUDE']) |
| 65 | # Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from |
| 66 | # the network. |
| 67 | llvm_config.with_environment('_NT_SYMBOL_PATH', '') |
| 68 | tools.append(ToolSubst('%cdb', '"%s"' % os.path.join(win_sdk, 'Debuggers', |
| 69 | arch, 'cdb.exe'))) |
| 70 | |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 71 | llvm_config.use_default_substitutions() |
| 72 | |
| 73 | # clang_src_dir is not used by these tests, but is required by |
| 74 | # use_clang(), so set it to "". |
| 75 | if not hasattr(config, 'clang_src_dir'): |
| 76 | config.clang_src_dir = "" |
| 77 | llvm_config.use_clang() |
| 78 | |
| 79 | if config.llvm_use_sanitizer: |
| 80 | # Propagate path to symbolizer for ASan/MSan. |
| 81 | llvm_config.with_system_environment( |
| 82 | ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']) |
| 83 | |
| 84 | tool_dirs = [config.llvm_tools_dir] |
| 85 | |
Don Hinton | 3a58f67 | 2017-12-12 16:54:20 +0000 | [diff] [blame] | 86 | llvm_config.add_tool_substitutions(tools, tool_dirs) |
| 87 | |
| 88 | lit.util.usePlatformSdkOnDarwin(config, lit_config) |
Vedant Kumar | efab30c | 2018-08-04 00:02:48 +0000 | [diff] [blame] | 89 | |
| 90 | if platform.system() == 'Darwin': |
Fangrui Song | 93deae2 | 2018-11-03 04:52:32 +0000 | [diff] [blame] | 91 | import subprocess |
| 92 | xcode_lldb_vers = subprocess.check_output(['xcrun', 'lldb', '--version']) |
Vedant Kumar | efab30c | 2018-08-04 00:02:48 +0000 | [diff] [blame] | 93 | match = re.search('lldb-(\d+)', xcode_lldb_vers) |
| 94 | if match: |
| 95 | apple_lldb_vers = int(match.group(1)) |
| 96 | if apple_lldb_vers < 1000: |
| 97 | config.available_features.add('apple-lldb-pre-1000') |