blob: dd0b0f7fd98b731a3d85e235d6f9bfb79969a9c5 [file] [log] [blame]
Don Hinton3a58f672017-12-12 16:54:20 +00001# -*- Python -*-
2
3import os
4import platform
5import re
6import subprocess
Jeremy Morse984fad22019-10-31 16:51:53 +00007import sys
Don Hinton3a58f672017-12-12 16:54:20 +00008import tempfile
9
10import lit.formats
11import lit.util
12
13from lit.llvm import llvm_config
14from lit.llvm.subst import ToolSubst
15from lit.llvm.subst import FindTool
16
17# Configuration file for the 'lit' test runner.
18
19# name: The name of this test suite.
20config.name = 'debuginfo-tests'
21
22# testFormat: The test format to use to interpret tests.
23#
24# For now we require '&&' between commands, until they get globally killed and
25# the test runner updated.
26config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
27
28# suffixes: A list of file extensions to treat as test files.
29config.suffixes = ['.c', '.cpp', '.m']
30
31# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
32# subdirectories contain auxiliary inputs for various tests in their parent
33# directories.
34config.excludes = ['Inputs']
35
36# test_source_root: The root path where tests are located.
37config.test_source_root = os.path.join(config.debuginfo_tests_src_root)
38
39# test_exec_root: The root path where tests should be run.
40config.test_exec_root = config.debuginfo_tests_obj_root
41
Jeremy Morse984fad22019-10-31 16:51:53 +000042llvm_config.use_default_substitutions()
43
Reid Kleckner75d38f12019-05-28 23:03:33 +000044tools = [
45 ToolSubst('%test_debuginfo', command=os.path.join(
Jeremy Morse984fad22019-10-31 16:51:53 +000046 config.debuginfo_tests_src_root, 'llgdb-tests', 'test_debuginfo.pl')),
Reid Kleckner75d38f12019-05-28 23:03:33 +000047]
48
49def get_required_attr(config, attr_name):
50 attr_value = getattr(config, attr_name, None)
51 if attr_value == None:
52 lit_config.fatal(
53 "No attribute %r in test configuration! You may need to run "
54 "tests from your build directory or add this attribute "
55 "to lit.site.cfg " % attr_name)
56 return attr_value
57
58# If this is an MSVC environment, the tests at the root of the tree are
59# unsupported. The local win_cdb test suite, however, is supported.
60is_msvc = get_required_attr(config, "is_msvc")
61if is_msvc:
Jeremy Morse984fad22019-10-31 16:51:53 +000062 config.available_features.add('msvc')
Reid Kleckner75d38f12019-05-28 23:03:33 +000063 # FIXME: We should add some llvm lit utility code to find the Windows SDK
64 # and set up the environment appopriately.
65 win_sdk = 'C:/Program Files (x86)/Windows Kits/10/'
66 arch = 'x64'
Reid Kleckner75d38f12019-05-28 23:03:33 +000067 llvm_config.with_system_environment(['LIB', 'LIBPATH', 'INCLUDE'])
68 # Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from
69 # the network.
70 llvm_config.with_environment('_NT_SYMBOL_PATH', '')
71 tools.append(ToolSubst('%cdb', '"%s"' % os.path.join(win_sdk, 'Debuggers',
72 arch, 'cdb.exe')))
73
Don Hinton3a58f672017-12-12 16:54:20 +000074# clang_src_dir is not used by these tests, but is required by
75# use_clang(), so set it to "".
76if not hasattr(config, 'clang_src_dir'):
77 config.clang_src_dir = ""
78llvm_config.use_clang()
79
80if config.llvm_use_sanitizer:
81 # Propagate path to symbolizer for ASan/MSan.
82 llvm_config.with_system_environment(
83 ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
Jeremy Morse984fad22019-10-31 16:51:53 +000084llvm_config.with_environment('PATHTOCLANG', llvm_config.config.clang)
85llvm_config.with_environment('PATHTOCLANGPP', llvm_config.use_llvm_tool('clang++'))
86llvm_config.with_environment('PATHTOCLANGCL', llvm_config.use_llvm_tool('clang-cl'))
87
88# Check which debuggers are available:
89built_lldb = llvm_config.use_llvm_tool('lldb', search_env='CLANG')
90if built_lldb is not None:
91 lldb_path = built_lldb
92elif lit.util.which('lldb') is not None:
93 lldb_path = lit.util.which('lldb')
94
95if lldb_path is not None:
96 config.available_features.add('lldb')
97
98# Produce dexter path, lldb path, and combine into the %dexter substitution
99dexter_path = os.path.join(config.debuginfo_tests_src_root,
100 'dexter', 'dexter.py')
101dexter_cmd = '{} {} test'.format(config.python3_executable, dexter_path)
102if lldb_path is not None:
103 dexter_cmd += ' --lldb-executable {}'.format(lldb_path)
104
105tools.append(ToolSubst('%dexter', dexter_cmd))
Don Hinton3a58f672017-12-12 16:54:20 +0000106
107tool_dirs = [config.llvm_tools_dir]
108
Don Hinton3a58f672017-12-12 16:54:20 +0000109llvm_config.add_tool_substitutions(tools, tool_dirs)
110
111lit.util.usePlatformSdkOnDarwin(config, lit_config)
Vedant Kumarefab30c2018-08-04 00:02:48 +0000112
Jeremy Morse984fad22019-10-31 16:51:53 +0000113# available_features: REQUIRES/UNSUPPORTED lit commands look at this list.
Vedant Kumarefab30c2018-08-04 00:02:48 +0000114if platform.system() == 'Darwin':
Fangrui Song93deae22018-11-03 04:52:32 +0000115 import subprocess
Jonas Devlieghere635eb802019-06-25 15:58:32 +0000116 xcode_lldb_vers = subprocess.check_output(['xcrun', 'lldb', '--version']).decode("utf-8")
Vedant Kumarefab30c2018-08-04 00:02:48 +0000117 match = re.search('lldb-(\d+)', xcode_lldb_vers)
118 if match:
119 apple_lldb_vers = int(match.group(1))
120 if apple_lldb_vers < 1000:
121 config.available_features.add('apple-lldb-pre-1000')
Jeremy Morse984fad22019-10-31 16:51:53 +0000122