3 # Configuration file for the 'lit' test runner.
12 # name: The name of this test suite.
13 config.name = 'lldb-api'
15 # suffixes: A list of file extensions to treat as test files.
16 config.suffixes = ['.py']
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.join(config.lldb_src_root, 'packages',
21 'Python', 'lldbsuite', 'test')
22 config.test_exec_root = config.test_source_root
24 if 'Address' in config.llvm_use_sanitizer:
25 config.environment['ASAN_OPTIONS'] = 'detect_stack_use_after_return=1'
26 # macOS flags needed for LLDB built with address sanitizer.
27 if 'Darwin' in config.host_os and 'x86' in config.host_triple:
29 resource_dir = subprocess.check_output(
30 [config.cmake_cxx_compiler,
31 '-print-resource-dir']).decode('utf-8').strip()
32 runtime = os.path.join(resource_dir, 'lib', 'darwin',
33 'libclang_rt.asan_osx_dynamic.dylib')
34 config.environment['DYLD_INSERT_LIBRARIES'] = runtime
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':
44 # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
45 if config.shared_libs:
46 for shlibpath_var in find_shlibpath_var():
47 # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
48 # llvm_libs_dir specifies LLVM's lib directory.
49 shlibpath = os.path.pathsep.join(
50 (config.llvm_shlib_dir, config.llvm_libs_dir,
51 config.environment.get(shlibpath_var, '')))
52 config.environment[shlibpath_var] = shlibpath
54 lit_config.warning("unable to inject shared library path on '{}'".format(
57 # Propagate LLDB_CAPTURE_REPRODUCER
58 if 'LLDB_CAPTURE_REPRODUCER' in os.environ:
59 config.environment['LLDB_CAPTURE_REPRODUCER'] = os.environ[
60 'LLDB_CAPTURE_REPRODUCER']
62 # Clean the module caches in the test build directory. This is necessary in an
63 # incremental build whenever clang changes underneath, so doing it once per
64 # lit.py invocation is close enough.
65 for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
66 if os.path.isdir(cachedir):
67 print("Deleting module cache at %s."%cachedir)
68 shutil.rmtree(cachedir)
70 # Set a default per-test timeout of 10 minutes. Setting a timeout per test
71 # requires that killProcessAndChildren() is supported on the platform and
72 # lit complains if the value is set but it is not supported.
73 supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
75 lit_config.maxIndividualTestTime = 600
77 lit_config.warning("Could not set a default per-test timeout. " + errormsg)
79 # Build dotest command.
80 dotest_cmd = [config.dotest_path]
81 dotest_cmd.extend(config.dotest_args_str.split(';'))
83 # We don't want to force users passing arguments to lit to use `;` as a
84 # separator. We use Python's simple lexical analyzer to turn the args into a
86 if config.dotest_lit_args_str:
87 dotest_cmd.extend(shlex.split(config.dotest_lit_args_str))
89 # Library path may be needed to locate just-built clang.
90 if config.llvm_libs_dir:
91 dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir]
93 if config.lldb_build_directory:
94 dotest_cmd += ['--build-dir', config.lldb_build_directory]
96 if config.lldb_module_cache:
97 dotest_cmd += ['--lldb-module-cache-dir', config.lldb_module_cache]
99 if config.clang_module_cache:
100 dotest_cmd += ['--clang-module-cache-dir', config.clang_module_cache]
102 # Load LLDB test format.
103 sys.path.append(os.path.join(config.lldb_src_root, "test", "API"))
106 # testFormat: The test format to use to interpret tests.
107 config.test_format = lldbtest.LLDBTest(dotest_cmd)