110 lines · python
1# -*- Python -*-2 3import shlex4import lit.util5 6from lit.llvm import llvm_config7from lit.llvm.subst import ToolSubst, FindTool8 9 10def shjoin(args, sep=" "):11 return sep.join([shlex.quote(arg) for arg in args])12 13 14# Configuration file for the 'lit' test runner.15 16# name: The name of this test suite.17config.name = "flang-rt"18 19# TODO: Consolidate the logic for turning on the internal shell by default for all LLVM test suites.20# See https://github.com/llvm/llvm-project/issues/106636 for more details.21#22# We prefer the lit internal shell which provides a better user experience on failures23# unless the user explicitly disables it with LIT_USE_INTERNAL_SHELL=0 env var.24use_lit_shell = True25lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")26if lit_shell_env:27 use_lit_shell = lit.util.pythonize_bool(lit_shell_env)28 29# testFormat: The test format to use to interpret tests.30#31# For now we require '&&' between commands, until they get globally killed and32# the test runner updated.33config.test_format = lit.formats.ShTest(not use_lit_shell)34 35# suffixes: A list of file extensions to treat as test files.36config.suffixes = [37 ".c",38 ".cpp",39 ".f",40 ".F",41 ".ff",42 ".FOR",43 ".for",44 ".f77",45 ".f90",46 ".F90",47 ".ff90",48 ".f95",49 ".F95",50 ".ff95",51 ".fpp",52 ".FPP",53 ".cuf",54 ".CUF",55 ".f18",56 ".F18",57 ".f03",58 ".F03",59 ".f08",60 ".F08",61 ".ll",62 ".fir",63 ".mlir",64]65 66llvm_config.use_default_substitutions()67 68# test_source_root: The root path where tests are located.69config.test_source_root = os.path.dirname(__file__)70 71# test_exec_root: The root path where tests should be run.72# lit writes a '.lit_test_times.txt' file into this directory.73config.test_exec_root = config.flang_rt_binary_test_dir74 75# On MacOS, some tests need -isysroot to build binaries.76isysroot_flag = []77if config.osx_sysroot:78 isysroot_flag = ["-isysroot", config.osx_sysroot]79config.substitutions.append(("%isysroot", " ".join(isysroot_flag)))80 81tools = [82 ToolSubst(83 "%flang",84 command=config.flang,85 unresolved="fatal",86 ),87 ToolSubst(88 "%clang",89 command=FindTool("clang"),90 unresolved="fatal",91 ),92 ToolSubst("%cc", command=config.cc, unresolved="fatal"),93]94llvm_config.add_tool_substitutions(tools)95 96# Let tests find LLVM's standard tools (FileCheck, split-file, not, ...)97llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)98 99# Include path for C headers that define Flang's Fortran ABI.100config.substitutions.append(101 ("%include", os.path.join(config.flang_source_dir, "include"))102)103 104# Library path of libflang_rt.runtime.a/.so (for lib search path when using non-Flang driver for linking and LD_LIBRARY_PATH)105config.substitutions.append(("%libdir", config.flang_rt_output_resource_lib_dir))106 107# For CUDA offloading, additional steps (device linking) and libraries (cudart) are needed.108if config.flang_rt_experimental_offload_support == "CUDA":109 config.available_features.add("offload-cuda")110