Mercurial > hg > CbC > CbC_llvm
comparison lldb/test/API/lit.cfg.py @ 150:1d019706d866
LLVM10
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 15:10:13 +0900 |
parents | |
children | 0572611fdcc8 |
comparison
equal
deleted
inserted
replaced
147:c2174574ed3a | 150:1d019706d866 |
---|---|
1 # -*- Python -*- | |
2 | |
3 # Configuration file for the 'lit' test runner. | |
4 | |
5 import os | |
6 import platform | |
7 import shlex | |
8 import shutil | |
9 | |
10 import lit.formats | |
11 | |
12 # name: The name of this test suite. | |
13 config.name = 'lldb-api' | |
14 | |
15 # suffixes: A list of file extensions to treat as test files. | |
16 config.suffixes = ['.py'] | |
17 | |
18 # test_source_root: The root path where tests are located. | |
19 # test_exec_root: The root path where tests should be run. | |
20 config.test_source_root = os.path.dirname(__file__) | |
21 config.test_exec_root = config.test_source_root | |
22 | |
23 if 'Address' in config.llvm_use_sanitizer: | |
24 config.environment['ASAN_OPTIONS'] = 'detect_stack_use_after_return=1' | |
25 # macOS flags needed for LLDB built with address sanitizer. | |
26 if 'Darwin' in config.host_os and 'x86' in config.host_triple: | |
27 import subprocess | |
28 resource_dir = subprocess.check_output( | |
29 [config.cmake_cxx_compiler, | |
30 '-print-resource-dir']).decode('utf-8').strip() | |
31 runtime = os.path.join(resource_dir, 'lib', 'darwin', | |
32 'libclang_rt.asan_osx_dynamic.dylib') | |
33 config.environment['DYLD_INSERT_LIBRARIES'] = runtime | |
34 | |
35 | |
36 def find_shlibpath_var(): | |
37 if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']: | |
38 yield 'LD_LIBRARY_PATH' | |
39 elif platform.system() == 'Darwin': | |
40 yield 'DYLD_LIBRARY_PATH' | |
41 elif platform.system() == 'Windows': | |
42 yield 'PATH' | |
43 | |
44 | |
45 # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent. | |
46 if config.shared_libs: | |
47 for shlibpath_var in find_shlibpath_var(): | |
48 # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while | |
49 # llvm_libs_dir specifies LLVM's lib directory. | |
50 shlibpath = os.path.pathsep.join( | |
51 (config.llvm_shlib_dir, config.llvm_libs_dir, | |
52 config.environment.get(shlibpath_var, ''))) | |
53 config.environment[shlibpath_var] = shlibpath | |
54 else: | |
55 lit_config.warning("unable to inject shared library path on '{}'".format( | |
56 platform.system())) | |
57 | |
58 # Propagate LLDB_CAPTURE_REPRODUCER | |
59 if 'LLDB_CAPTURE_REPRODUCER' in os.environ: | |
60 config.environment['LLDB_CAPTURE_REPRODUCER'] = os.environ[ | |
61 'LLDB_CAPTURE_REPRODUCER'] | |
62 | |
63 # Clean the module caches in the test build directory. This is necessary in an | |
64 # incremental build whenever clang changes underneath, so doing it once per | |
65 # lit.py invocation is close enough. | |
66 for cachedir in [config.clang_module_cache, config.lldb_module_cache]: | |
67 if os.path.isdir(cachedir): | |
68 print("Deleting module cache at %s." % cachedir) | |
69 shutil.rmtree(cachedir) | |
70 | |
71 # Set a default per-test timeout of 10 minutes. Setting a timeout per test | |
72 # requires that killProcessAndChildren() is supported on the platform and | |
73 # lit complains if the value is set but it is not supported. | |
74 supported, errormsg = lit_config.maxIndividualTestTimeIsSupported | |
75 if supported: | |
76 lit_config.maxIndividualTestTime = 600 | |
77 else: | |
78 lit_config.warning("Could not set a default per-test timeout. " + errormsg) | |
79 | |
80 # Build dotest command. | |
81 dotest_cmd = [config.dotest_path] | |
82 dotest_cmd += ['--arch', config.test_arch] | |
83 dotest_cmd.extend(config.dotest_args_str.split(';')) | |
84 | |
85 # Library path may be needed to locate just-built clang. | |
86 if config.llvm_libs_dir: | |
87 dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir] | |
88 | |
89 # Forward ASan-specific environment variables to tests, as a test may load an | |
90 # ASan-ified dylib. | |
91 for env_var in ('ASAN_OPTIONS', 'DYLD_INSERT_LIBRARIES'): | |
92 if env_var in config.environment: | |
93 dotest_cmd += ['--inferior-env', env_var + '=' + config.environment[env_var]] | |
94 | |
95 if config.lldb_build_directory: | |
96 dotest_cmd += ['--build-dir', config.lldb_build_directory] | |
97 | |
98 if config.lldb_module_cache: | |
99 dotest_cmd += ['--lldb-module-cache-dir', config.lldb_module_cache] | |
100 | |
101 if config.clang_module_cache: | |
102 dotest_cmd += ['--clang-module-cache-dir', config.clang_module_cache] | |
103 | |
104 if config.lldb_executable: | |
105 dotest_cmd += ['--executable', config.lldb_executable] | |
106 | |
107 if config.test_compiler: | |
108 dotest_cmd += ['--compiler', config.test_compiler] | |
109 | |
110 if config.dsymutil: | |
111 dotest_cmd += ['--dsymutil', config.dsymutil] | |
112 | |
113 if config.filecheck: | |
114 dotest_cmd += ['--filecheck', config.filecheck] | |
115 | |
116 if config.lldb_libs_dir: | |
117 dotest_cmd += ['--lldb-libs-dir', config.lldb_libs_dir] | |
118 | |
119 # We don't want to force users passing arguments to lit to use `;` as a | |
120 # separator. We use Python's simple lexical analyzer to turn the args into a | |
121 # list. Pass there arguments last so they can override anything that was | |
122 # already configured. | |
123 if config.dotest_lit_args_str: | |
124 dotest_cmd.extend(shlex.split(config.dotest_lit_args_str)) | |
125 | |
126 | |
127 # Load LLDB test format. | |
128 sys.path.append(os.path.join(config.lldb_src_root, "test", "API")) | |
129 import lldbtest | |
130 | |
131 # testFormat: The test format to use to interpret tests. | |
132 config.test_format = lldbtest.LLDBTest(dotest_cmd) |