xref: /llvm-project/compiler-rt/test/nsan/lit.cfg.py (revision f4e8fbc5e90a4f2959a0eb6d7b01e7e279fb693b)
1*f4e8fbc5SAlexander Shaposhnikovconfig.name = "NSan" + config.name_suffix
2cae6d458SAlexander Shaposhnikov
3*f4e8fbc5SAlexander Shaposhnikov# Setup source root.
4*f4e8fbc5SAlexander Shaposhnikovconfig.test_source_root = os.path.dirname(__file__)
5*f4e8fbc5SAlexander Shaposhnikov
6*f4e8fbc5SAlexander Shaposhnikov# Test suffixes.
7*f4e8fbc5SAlexander Shaposhnikovconfig.suffixes = [".c", ".cpp", ".test"]
8*f4e8fbc5SAlexander Shaposhnikov
9*f4e8fbc5SAlexander Shaposhnikov# C & CXX flags.
10*f4e8fbc5SAlexander Shaposhnikovc_flags = [config.target_cflags]
11*f4e8fbc5SAlexander Shaposhnikov
12*f4e8fbc5SAlexander Shaposhnikov# CXX flags
13*f4e8fbc5SAlexander Shaposhnikovcxx_flags = c_flags + config.cxx_mode_flags + ["-std=c++17"]
14*f4e8fbc5SAlexander Shaposhnikov
15*f4e8fbc5SAlexander Shaposhnikovnsan_flags = [
16*f4e8fbc5SAlexander Shaposhnikov    "-fsanitize=numerical",
17*f4e8fbc5SAlexander Shaposhnikov    "-g",
18*f4e8fbc5SAlexander Shaposhnikov    "-mno-omit-leaf-frame-pointer",
19*f4e8fbc5SAlexander Shaposhnikov    "-fno-omit-frame-pointer",
20*f4e8fbc5SAlexander Shaposhnikov]
21*f4e8fbc5SAlexander Shaposhnikov
22*f4e8fbc5SAlexander Shaposhnikov
23*f4e8fbc5SAlexander Shaposhnikovdef build_invocation(compile_flags):
24*f4e8fbc5SAlexander Shaposhnikov    return " " + " ".join([config.clang] + compile_flags) + " "
25*f4e8fbc5SAlexander Shaposhnikov
26*f4e8fbc5SAlexander Shaposhnikov
27*f4e8fbc5SAlexander Shaposhnikov# Add substitutions.
28*f4e8fbc5SAlexander Shaposhnikovconfig.substitutions.append(("%clang ", build_invocation(c_flags)))
29*f4e8fbc5SAlexander Shaposhnikovconfig.substitutions.append(("%clang_nsan ", build_invocation(c_flags + nsan_flags)))
30*f4e8fbc5SAlexander Shaposhnikovconfig.substitutions.append(
31*f4e8fbc5SAlexander Shaposhnikov    ("%clangxx_nsan ", build_invocation(cxx_flags + nsan_flags))
32*f4e8fbc5SAlexander Shaposhnikov)
33*f4e8fbc5SAlexander Shaposhnikov
34*f4e8fbc5SAlexander Shaposhnikov# NSan tests are currently supported on Linux only.
35*f4e8fbc5SAlexander Shaposhnikovif config.host_os not in ["Linux"]:
36*f4e8fbc5SAlexander Shaposhnikov    config.unsupported = True
37