xref: /llvm-project/llvm/test/Unit/lit.cfg.py (revision f8559751fc2b15b45ac417be9abe865085af45ad)
1# -*- Python -*-
2
3# Configuration file for the 'lit' test runner.
4
5import os
6import subprocess
7
8import lit.formats
9
10# name: The name of this test suite.
11config.name = "LLVM-Unit"
12
13# suffixes: A list of file extensions to treat as test files.
14config.suffixes = []
15
16# test_source_root: The root path where tests are located.
17# test_exec_root: The root path where tests should be run.
18config.test_exec_root = os.path.join(config.llvm_obj_root, "unittests")
19config.test_source_root = config.test_exec_root
20
21# testFormat: The test format to use to interpret tests.
22config.test_format = lit.formats.GoogleTest(
23    config.llvm_build_mode,
24    "Tests",
25    run_under=config.gtest_run_under,
26)
27
28# Propagate the temp directory. Windows requires this because it uses \Windows\
29# if none of these are present.
30if "TMP" in os.environ:
31    config.environment["TMP"] = os.environ["TMP"]
32if "TEMP" in os.environ:
33    config.environment["TEMP"] = os.environ["TEMP"]
34
35# Propagate HOME as it can be used to override incorrect homedir in passwd
36# that causes the tests to fail.
37if "HOME" in os.environ:
38    config.environment["HOME"] = os.environ["HOME"]
39
40# Propagate sanitizer options.
41for var in [
42    "ASAN_SYMBOLIZER_PATH",
43    "HWASAN_SYMBOLIZER_PATH",
44    "MSAN_SYMBOLIZER_PATH",
45    "TSAN_SYMBOLIZER_PATH",
46    "UBSAN_SYMBOLIZER_PATH",
47    "ASAN_OPTIONS",
48    "HWASAN_OPTIONS",
49    "MSAN_OPTIONS",
50    "RTSAN_OPTIONS",
51    "TSAN_OPTIONS",
52    "UBSAN_OPTIONS",
53]:
54    if var in os.environ:
55        config.environment[var] = os.environ[var]
56
57# Win32 seeks DLLs along %PATH%.
58if sys.platform in ["win32", "cygwin"] and os.path.isdir(config.shlibdir):
59    config.environment["PATH"] = os.path.pathsep.join(
60        (config.shlibdir, config.environment["PATH"])
61    )
62
63# Win32 may use %SYSTEMDRIVE% during file system shell operations, so propagate.
64if sys.platform == "win32" and "SYSTEMDRIVE" in os.environ:
65    config.environment["SYSTEMDRIVE"] = os.environ["SYSTEMDRIVE"]
66