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, '-print-resource-dir']).strip()
31 runtime = os.path.join(resource_dir, 'lib', 'darwin',
32 'libclang_rt.asan_osx_dynamic.dylib')
33 config.environment['DYLD_INSERT_LIBRARIES'] = runtime
35 def find_shlibpath_var():
36 if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
37 yield 'LD_LIBRARY_PATH'
38 elif platform.system() == 'Darwin':
39 yield 'DYLD_LIBRARY_PATH'
40 elif platform.system() == 'Windows':
43 # Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent.
44 if config.shared_libs:
45 for shlibpath_var in find_shlibpath_var():
46 # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory while
47 # llvm_libs_dir specifies LLVM's lib directory.
48 shlibpath = os.path.pathsep.join(
49 (config.llvm_shlib_dir, config.llvm_libs_dir,
50 config.environment.get(shlibpath_var, '')))
51 config.environment[shlibpath_var] = shlibpath
53 lit_config.warning("unable to inject shared library path on '{}'".format(
56 # Clean the module caches in the test build directory. This is necessary in an
57 # incremental build whenever clang changes underneath, so doing it once per
58 # lit.py invocation is close enough.
59 for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
60 if os.path.isdir(cachedir):
61 print("Deleting module cache at %s."%cachedir)
62 shutil.rmtree(cachedir)
64 # Set a default per-test timeout of 10 minutes. Setting a timeout per test
65 # requires that killProcessAndChildren() is supported on the platform and
66 # lit complains if the value is set but it is not supported.
67 supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
69 lit_config.maxIndividualTestTime = 600
71 lit_config.warning("Could not set a default per-test timeout. " + errormsg)
73 # Build dotest command.
74 dotest_cmd = [config.dotest_path]
75 dotest_cmd.extend(config.dotest_args_str.split(';'))
77 # We don't want to force users passing arguments to lit to use `;` as a
78 # separator. We use Python's simple lexical analyzer to turn the args into a
80 if config.dotest_lit_args_str:
81 dotest_cmd.extend(shlex.split(config.dotest_lit_args_str))
83 # Library path may be needed to locate just-built clang.
84 if config.llvm_libs_dir:
85 dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir]
87 if config.lldb_build_directory:
88 dotest_cmd += ['--build-dir', config.lldb_build_directory]
90 if config.lldb_module_cache:
91 dotest_cmd += ['--lldb-module-cache-dir', config.lldb_module_cache]
93 if config.clang_module_cache:
94 dotest_cmd += ['--clang-module-cache-dir', config.clang_module_cache]
96 # Load LLDB test format.
97 sys.path.append(os.path.join(config.lldb_src_root, "test", "API"))
100 # testFormat: The test format to use to interpret tests.
101 config.test_format = lldbtest.LLDBTest(dotest_cmd)