[DebugInfo][RemoveDIs] Emulate inserting insts in dbg.value sequences (#73350)
[llvm-project.git] / flang / test / lit.cfg.py
blobac504dc5d1fbdfa2e5eab10e9e11ec6582746d9a
1 # -*- Python -*-
3 import os
4 import platform
5 import re
6 import subprocess
7 import sys
9 import lit.formats
10 import lit.util
12 from lit.llvm import llvm_config
13 from lit.llvm.subst import ToolSubst
14 from lit.llvm.subst import FindTool
16 # Configuration file for the 'lit' test runner.
18 # name: The name of this test suite.
19 config.name = "Flang"
21 # testFormat: The test format to use to interpret tests.
23 # For now we require '&&' between commands, until they get globally killed and
24 # the test runner updated.
25 config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
27 # suffixes: A list of file extensions to treat as test files.
28 config.suffixes = [
29 ".c",
30 ".cpp",
31 ".f",
32 ".F",
33 ".ff",
34 ".FOR",
35 ".for",
36 ".f77",
37 ".f90",
38 ".F90",
39 ".ff90",
40 ".f95",
41 ".F95",
42 ".ff95",
43 ".fpp",
44 ".FPP",
45 ".cuf",
46 ".CUF",
47 ".f18",
48 ".F18",
49 ".f03",
50 ".F03",
51 ".f08",
52 ".F08",
53 ".ll",
54 ".fir",
55 ".mlir",
58 config.substitutions.append(("%PATH%", config.environment["PATH"]))
59 config.substitutions.append(("%llvmshlibdir", config.llvm_shlib_dir))
60 config.substitutions.append(("%pluginext", config.llvm_plugin_ext))
62 llvm_config.use_default_substitutions()
64 # ask llvm-config about asserts
65 llvm_config.feature_config([("--assertion-mode", {"ON": "asserts"})])
67 # Targets
68 config.targets = frozenset(config.targets_to_build.split())
69 for arch in config.targets_to_build.split():
70 config.available_features.add(arch.lower() + "-registered-target")
72 # To modify the default target triple for flang tests.
73 if config.flang_test_triple:
74 config.target_triple = config.flang_test_triple
75 config.environment[config.llvm_target_triple_env] = config.flang_test_triple
77 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
78 # subdirectories contain auxiliary inputs for various tests in their parent
79 # directories.
80 config.excludes = ["Inputs", "CMakeLists.txt", "README.txt", "LICENSE.txt"]
82 # If the flang examples are built, add examples to the config
83 if config.flang_examples:
84 config.available_features.add("examples")
86 # Plugins (loadable modules)
87 if config.has_plugins:
88 config.available_features.add("plugins")
90 if config.linked_bye_extension:
91 config.substitutions.append(("%loadbye", ""))
92 else:
93 config.substitutions.append(
95 "%loadbye",
96 "-fpass-plugin={}/Bye{}".format(
97 config.llvm_shlib_dir, config.llvm_plugin_ext
102 # test_source_root: The root path where tests are located.
103 config.test_source_root = os.path.dirname(__file__)
105 # test_exec_root: The root path where tests should be run.
106 config.test_exec_root = os.path.join(config.flang_obj_root, "test")
108 # Tweak the PATH to include the tools dir.
109 llvm_config.with_environment("PATH", config.flang_tools_dir, append_path=True)
110 llvm_config.with_environment("PATH", config.llvm_tools_dir, append_path=True)
112 if config.flang_standalone_build:
113 # For builds with FIR, set path for tco and enable related tests
114 if config.flang_llvm_tools_dir != "":
115 config.available_features.add("fir")
116 if config.llvm_tools_dir != config.flang_llvm_tools_dir:
117 llvm_config.with_environment(
118 "PATH", config.flang_llvm_tools_dir, append_path=True
121 # For each occurrence of a flang tool name, replace it with the full path to
122 # the build directory holding that tool.
123 tools = [
124 ToolSubst("%flang", command=FindTool("flang-new"), unresolved="fatal"),
125 ToolSubst(
126 "%flang_fc1",
127 command=FindTool("flang-new"),
128 extra_args=["-fc1"],
129 unresolved="fatal",
133 # Flang has several unimplemented features. TODO messages are used to mark
134 # and fail if these features are exercised. Some TODOs exit with a non-zero
135 # exit code, but others abort the execution in assert builds.
136 # To catch aborts, the `--crash` option for the `not` command has to be used.
137 tools.append(ToolSubst("%not_todo_cmd", command=FindTool("not"), unresolved="fatal"))
138 if "asserts" in config.available_features:
139 tools.append(
140 ToolSubst(
141 "%not_todo_abort_cmd",
142 command=FindTool("not"),
143 extra_args=["--crash"],
144 unresolved="fatal",
147 else:
148 tools.append(
149 ToolSubst("%not_todo_abort_cmd", command=FindTool("not"), unresolved="fatal")
152 # Define some variables to help us test that the flang runtime doesn't depend on
153 # the C++ runtime libraries. For this we need a C compiler. If for some reason
154 # we don't have one, we can just disable the test.
155 if config.cc:
156 libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
157 libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
158 include = os.path.join(config.flang_src_dir, "include")
160 if (
161 os.path.isfile(libruntime)
162 and os.path.isfile(libdecimal)
163 and os.path.isdir(include)
165 config.available_features.add("c-compiler")
166 cc_cmd = config.cc
167 if config.osx_sysroot:
168 cc_cmd += " -isysroot " + config.osx_sysroot
169 tools.append(ToolSubst("%cc", command=cc_cmd, unresolved="fatal"))
170 tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
171 tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal"))
172 tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
174 # Add all the tools and their substitutions (if applicable). Use the search paths provided for
175 # finding the tools.
176 if config.flang_standalone_build:
177 llvm_config.add_tool_substitutions(
178 tools, [config.flang_llvm_tools_dir, config.llvm_tools_dir]
180 else:
181 llvm_config.add_tool_substitutions(tools, config.llvm_tools_dir)
183 # Enable libpgmath testing
184 result = lit_config.params.get("LIBPGMATH")
185 if result:
186 config.environment["LIBPGMATH"] = True