blob: 126f6a0571d6d0283e28aabd6fd76a60aefca8aa [file] [log] [blame]
Don Hinton3a58f672017-12-12 16:54:20 +00001# -*- Python -*-
2
3import os
4import platform
5import re
6import subprocess
7import tempfile
8
9import lit.formats
10import lit.util
11
12from lit.llvm import llvm_config
13from lit.llvm.subst import ToolSubst
14from lit.llvm.subst import FindTool
15
16# Configuration file for the 'lit' test runner.
17
18# name: The name of this test suite.
19config.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.
25config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
26
27# suffixes: A list of file extensions to treat as test files.
28config.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.
33config.excludes = ['Inputs']
34
35# test_source_root: The root path where tests are located.
36config.test_source_root = os.path.join(config.debuginfo_tests_src_root)
37
38# test_exec_root: The root path where tests should be run.
39config.test_exec_root = config.debuginfo_tests_obj_root
40
Reid Kleckner75d38f12019-05-28 23:03:33 +000041tools = [
42 ToolSubst('%test_debuginfo', command=os.path.join(
43 config.debuginfo_tests_src_root, 'test_debuginfo.pl')),
44]
45
46def 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.
57is_msvc = get_required_attr(config, "is_msvc")
58if 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 Hinton3a58f672017-12-12 16:54:20 +000071llvm_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 "".
75if not hasattr(config, 'clang_src_dir'):
76 config.clang_src_dir = ""
77llvm_config.use_clang()
78
79if 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
84tool_dirs = [config.llvm_tools_dir]
85
Don Hinton3a58f672017-12-12 16:54:20 +000086llvm_config.add_tool_substitutions(tools, tool_dirs)
87
88lit.util.usePlatformSdkOnDarwin(config, lit_config)
Vedant Kumarefab30c2018-08-04 00:02:48 +000089
90if platform.system() == 'Darwin':
Fangrui Song93deae22018-11-03 04:52:32 +000091 import subprocess
Jonas Devlieghere635eb802019-06-25 15:58:32 +000092 xcode_lldb_vers = subprocess.check_output(['xcrun', 'lldb', '--version']).decode("utf-8")
Vedant Kumarefab30c2018-08-04 00:02:48 +000093 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')