xref: /llvm-project/clang/test/Unit/lit.cfg.py (revision fe3f6c63cd6b75433a72b980a23d9848d19abdc2)
1bbe23ae6SZachary Turner# -*- Python -*-
2bbe23ae6SZachary Turner
3bbe23ae6SZachary Turner# Configuration file for the 'lit' test runner.
4bbe23ae6SZachary Turner
5bbe23ae6SZachary Turnerimport os
6bbe23ae6SZachary Turnerimport platform
7bbe23ae6SZachary Turnerimport subprocess
8bbe23ae6SZachary Turner
9bbe23ae6SZachary Turnerimport lit.formats
10bbe23ae6SZachary Turnerimport lit.util
11bbe23ae6SZachary Turner
12bbe23ae6SZachary Turner# name: The name of this test suite.
13dd3c26a0STobias Hietaconfig.name = "Clang-Unit"
14bbe23ae6SZachary Turner
15bbe23ae6SZachary Turner# suffixes: A list of file extensions to treat as test files.
16bbe23ae6SZachary Turnerconfig.suffixes = []
17bbe23ae6SZachary Turner
18bbe23ae6SZachary Turner# test_source_root: The root path where tests are located.
19bbe23ae6SZachary Turner# test_exec_root: The root path where tests should be run.
20dd3c26a0STobias Hietaconfig.test_exec_root = os.path.join(config.clang_obj_root, "unittests")
21bbe23ae6SZachary Turnerconfig.test_source_root = config.test_exec_root
22bbe23ae6SZachary Turner
23bbe23ae6SZachary Turner# testFormat: The test format to use to interpret tests.
24dd3c26a0STobias Hietaconfig.test_format = lit.formats.GoogleTest(config.llvm_build_mode, "Tests")
25bbe23ae6SZachary Turner
26bbe23ae6SZachary Turner# Propagate the temp directory. Windows requires this because it uses \Windows\
27bbe23ae6SZachary Turner# if none of these are present.
28*fe3f6c63SKrystian Stasiowskifor v in ["TMP", "TEMP", "HOME", "SystemDrive"]:
29*fe3f6c63SKrystian Stasiowski    if v in os.environ:
30*fe3f6c63SKrystian Stasiowski        config.environment[v] = os.environ[v]
317fe47575SColin Cross
32d33c3623SVitaly Buka# Propagate sanitizer options.
33d33c3623SVitaly Bukafor var in [
34dd3c26a0STobias Hieta    "ASAN_SYMBOLIZER_PATH",
35dd3c26a0STobias Hieta    "HWASAN_SYMBOLIZER_PATH",
36dd3c26a0STobias Hieta    "MSAN_SYMBOLIZER_PATH",
37dd3c26a0STobias Hieta    "TSAN_SYMBOLIZER_PATH",
38dd3c26a0STobias Hieta    "UBSAN_SYMBOLIZER_PATH",
39dd3c26a0STobias Hieta    "ASAN_OPTIONS",
40dd3c26a0STobias Hieta    "HWASAN_OPTIONS",
41dd3c26a0STobias Hieta    "MSAN_OPTIONS",
42dd3c26a0STobias Hieta    "TSAN_OPTIONS",
43dd3c26a0STobias Hieta    "UBSAN_OPTIONS",
44d33c3623SVitaly Buka]:
45d33c3623SVitaly Buka    if var in os.environ:
46d33c3623SVitaly Buka        config.environment[var] = os.environ[var]
47bbe23ae6SZachary Turner
48dd3c26a0STobias Hieta
49cc5bf00fSTim Shendef find_shlibpath_var():
50dd3c26a0STobias Hieta    if platform.system() in ["Linux", "FreeBSD", "NetBSD", "OpenBSD", "SunOS"]:
51dd3c26a0STobias Hieta        yield "LD_LIBRARY_PATH"
52dd3c26a0STobias Hieta    elif platform.system() == "Darwin":
53dd3c26a0STobias Hieta        yield "DYLD_LIBRARY_PATH"
54dd3c26a0STobias Hieta    elif platform.system() == "Windows":
55dd3c26a0STobias Hieta        yield "PATH"
56dd3c26a0STobias Hieta    elif platform.system() == "AIX":
57dd3c26a0STobias Hieta        yield "LIBPATH"
58dd3c26a0STobias Hieta
59bbe23ae6SZachary Turner
60cc5bf00fSTim Shenfor shlibpath_var in find_shlibpath_var():
61bbe23ae6SZachary Turner    # in stand-alone builds, shlibdir is clang's build tree
62bbe23ae6SZachary Turner    # while llvm_libs_dir is installed LLVM (and possibly older clang)
63cc5bf00fSTim Shen    shlibpath = os.path.pathsep.join(
64dd3c26a0STobias Hieta        (
65dd3c26a0STobias Hieta            config.shlibdir,
66cc5bf00fSTim Shen            config.llvm_libs_dir,
67dd3c26a0STobias Hieta            config.environment.get(shlibpath_var, ""),
68dd3c26a0STobias Hieta        )
69dd3c26a0STobias Hieta    )
70bbe23ae6SZachary Turner    config.environment[shlibpath_var] = shlibpath
71cc5bf00fSTim Shen    break
72cc5bf00fSTim Shenelse:
73dd3c26a0STobias Hieta    lit_config.warning(
74dd3c26a0STobias Hieta        "unable to inject shared library path on '{}'".format(platform.system())
75dd3c26a0STobias Hieta    )
76924996e0SMichał Górny
77924996e0SMichał Górny# It is not realistically possible to account for all options that could
78924996e0SMichał Górny# possibly be present in system and user configuration files, so disable
79924996e0SMichał Górny# default configs for the test runs.
80924996e0SMichał Górnyconfig.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
81