12 from lit
.llvm
import llvm_config
13 from lit
.llvm
.subst
import ToolSubst
15 # Configuration file for the 'lit' test runner.
17 # name: The name of this test suite.
18 config
.name
= 'debuginfo-tests'
20 # testFormat: The test format to use to interpret tests.
22 # For now we require '&&' between commands, until they get globally killed and
23 # the test runner updated.
24 config
.test_format
= lit
.formats
.ShTest(not llvm_config
.use_lit_shell
)
26 # suffixes: A list of file extensions to treat as test files.
27 config
.suffixes
= ['.c', '.cpp', '.m']
29 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
30 # subdirectories contain auxiliary inputs for various tests in their parent
32 config
.excludes
= ['Inputs']
34 # test_source_root: The root path where tests are located.
35 config
.test_source_root
= os
.path
.join(config
.debuginfo_tests_src_root
)
37 # test_exec_root: The root path where tests should be run.
38 config
.test_exec_root
= config
.debuginfo_tests_obj_root
40 llvm_config
.use_default_substitutions()
43 ToolSubst('%test_debuginfo', command
=os
.path
.join(
44 config
.debuginfo_tests_src_root
, 'llgdb-tests', 'test_debuginfo.pl')),
45 ToolSubst("%llvm_src_root", config
.llvm_src_root
),
46 ToolSubst("%llvm_tools_dir", config
.llvm_tools_dir
),
49 def get_required_attr(config
, attr_name
):
50 attr_value
= getattr(config
, attr_name
, None)
51 if attr_value
== None:
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
)
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.
60 is_msvc
= get_required_attr(config
, "is_msvc")
62 config
.available_features
.add('msvc')
63 # 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/'
67 llvm_config
.with_system_environment(['LIB', 'LIBPATH', 'INCLUDE'])
68 # Clear _NT_SYMBOL_PATH to prevent cdb from attempting to load symbols from
70 llvm_config
.with_environment('_NT_SYMBOL_PATH', '')
71 tools
.append(ToolSubst('%cdb', '"%s"' % os
.path
.join(win_sdk
, 'Debuggers',
74 # clang_src_dir is not used by these tests, but is required by
75 # use_clang(), so set it to "".
76 if not hasattr(config
, 'clang_src_dir'):
77 config
.clang_src_dir
= ""
78 llvm_config
.use_clang()
80 if 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'])
85 def add_host_triple(clang
):
86 return '{} --target={}'.format(clang
, config
.host_triple
)
88 # The set of arches we can build.
89 targets
= set(config
.targets_to_build
)
90 # Add aliases to the target set.
91 if 'AArch64' in targets
:
93 if 'ARM' in config
.targets_to_build
:
94 targets
.add('thumbv7')
96 def can_target_host():
97 # Check if the targets set contains anything that looks like our host arch.
98 # The arch name in the triple and targets set may be spelled differently
100 return any(config
.host_triple
.lower().startswith(x
.lower())
103 # Dexter tests run on the host machine. If the host arch is supported add
104 # 'dexter' as an available feature and force the dexter tests to use the host
106 if can_target_host():
107 config
.available_features
.add('dexter')
108 if config
.host_triple
!= config
.target_triple
:
109 print('Forcing dexter tests to use host triple {}.'.format(config
.host_triple
))
110 llvm_config
.with_environment('PATHTOCLANG',
111 add_host_triple(llvm_config
.config
.clang
))
112 llvm_config
.with_environment('PATHTOCLANGPP',
113 add_host_triple(llvm_config
.use_llvm_tool('clang++')))
114 llvm_config
.with_environment('PATHTOCLANGCL',
115 add_host_triple(llvm_config
.use_llvm_tool('clang-cl')))
117 print('Host triple {} not supported. Skipping dexter tests in the '
118 'debuginfo-tests project.'.format(config
.host_triple
))
120 # Check which debuggers are available:
121 built_lldb
= llvm_config
.use_llvm_tool('lldb', search_env
='CLANG')
123 if built_lldb
is not None:
124 lldb_path
= built_lldb
125 elif lit
.util
.which('lldb') is not None:
126 lldb_path
= lit
.util
.which('lldb')
128 if lldb_path
is not None:
129 config
.available_features
.add('lldb')
131 # Produce dexter path, lldb path, and combine into the %dexter substitution
132 # for running a test.
133 dexter_path
= os
.path
.join(config
.debuginfo_tests_src_root
,
134 'dexter', 'dexter.py')
135 dexter_test_cmd
= '"{}" "{}" test'.format(sys
.executable
, dexter_path
)
136 if lldb_path
is not None:
137 dexter_test_cmd
+= ' --lldb-executable "{}"'.format(lldb_path
)
138 tools
.append(ToolSubst('%dexter', dexter_test_cmd
))
140 # For testing other bits of dexter that aren't under the "test" subcommand,
141 # have a %dexter_base substitution.
142 dexter_base_cmd
= '"{}" "{}"'.format(sys
.executable
, dexter_path
)
143 tools
.append(ToolSubst('%dexter_base', dexter_base_cmd
))
145 # Set up commands for DexTer regression tests.
146 # Builder, debugger, optimisation level and several other flags differ
147 # depending on whether we're running a unix like or windows os.
148 if platform
.system() == 'Windows':
149 dexter_regression_test_builder
= '--builder clang-cl_vs2015'
150 dexter_regression_test_debugger
= '--debugger dbgeng'
151 dexter_regression_test_cflags
= '--cflags "/Zi /Od"'
152 dexter_regression_test_ldflags
= '--ldflags "/Zi"'
154 dexter_regression_test_builder
= '--builder clang'
155 dexter_regression_test_debugger
= "--debugger lldb"
156 dexter_regression_test_cflags
= '--cflags "-O0 -glldb"'
157 dexter_regression_test_ldflags
= ''
159 # Typical command would take the form:
160 # ./path_to_py/python.exe ./path_to_dex/dexter.py test --fail-lt 1.0 -w --builder clang --debugger lldb --cflags '-O0 -g'
161 dexter_regression_test_command
= ' '.join(
162 # "python", "dexter.py", test, fail_mode, builder, debugger, cflags, ldflags
163 ['"{}"'.format(sys
.executable
),
164 '"{}"'.format(dexter_path
),
167 dexter_regression_test_builder
,
168 dexter_regression_test_debugger
,
169 dexter_regression_test_cflags
,
170 dexter_regression_test_ldflags
])
172 tools
.append(ToolSubst('%dexter_regression_test', dexter_regression_test_command
))
174 tool_dirs
= [config
.llvm_tools_dir
]
176 llvm_config
.add_tool_substitutions(tools
, tool_dirs
)
178 lit
.util
.usePlatformSdkOnDarwin(config
, lit_config
)
180 # available_features: REQUIRES/UNSUPPORTED lit commands look at this list.
181 if platform
.system() == 'Darwin':
182 xcode_lldb_vers
= subprocess
.check_output(['xcrun', 'lldb', '--version']).decode("utf-8")
183 match
= re
.search('lldb-(\d+)', xcode_lldb_vers
)
185 apple_lldb_vers
= int(match
.group(1))
186 if apple_lldb_vers
< 1000:
187 config
.available_features
.add('apple-lldb-pre-1000')
189 llvm_config
.feature_config(
190 [('--build-mode', {'Debug|RelWithDebInfo': 'debug-info'})]