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.
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.
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"})])
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
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", ""))
93 config
.substitutions
.append(
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 # On MacOS, -isysroot is needed to build binaries.
123 if config
.osx_sysroot
:
124 isysroot_flag
= ["-isysroot", config
.osx_sysroot
]
126 # Check for DEFAULT_SYSROOT, because when it is set -isysroot has no effect.
127 if config
.default_sysroot
:
128 config
.available_features
.add("default_sysroot")
130 # For each occurrence of a flang tool name, replace it with the full path to
131 # the build directory holding that tool.
135 command
=FindTool("flang"),
136 extra_args
=isysroot_flag
,
141 command
=FindTool("flang"),
147 # Flang has several unimplemented features. TODO messages are used to mark
148 # and fail if these features are exercised. Some TODOs exit with a non-zero
149 # exit code, but others abort the execution in assert builds.
150 # To catch aborts, the `--crash` option for the `not` command has to be used.
151 tools
.append(ToolSubst("%not_todo_cmd", command
=FindTool("not"), unresolved
="fatal"))
152 if "asserts" in config
.available_features
:
155 "%not_todo_abort_cmd",
156 command
=FindTool("not"),
157 extra_args
=["--crash"],
163 ToolSubst("%not_todo_abort_cmd", command
=FindTool("not"), unresolved
="fatal")
166 # Define some variables to help us test that the flang runtime doesn't depend on
167 # the C++ runtime libraries. For this we need a C compiler. If for some reason
168 # we don't have one, we can just disable the test.
170 libruntime
= os
.path
.join(config
.flang_lib_dir
, "libFortranRuntime.a")
171 libdecimal
= os
.path
.join(config
.flang_lib_dir
, "libFortranDecimal.a")
172 include
= os
.path
.join(config
.flang_src_dir
, "include")
175 os
.path
.isfile(libruntime
)
176 and os
.path
.isfile(libdecimal
)
177 and os
.path
.isdir(include
)
179 config
.available_features
.add("c-compiler")
182 "%cc", command
=config
.cc
, extra_args
=isysroot_flag
, unresolved
="fatal"
185 tools
.append(ToolSubst("%libruntime", command
=libruntime
, unresolved
="fatal"))
186 tools
.append(ToolSubst("%libdecimal", command
=libdecimal
, unresolved
="fatal"))
187 tools
.append(ToolSubst("%include", command
=include
, unresolved
="fatal"))
189 # Add all the tools and their substitutions (if applicable). Use the search paths provided for
191 if config
.flang_standalone_build
:
192 llvm_config
.add_tool_substitutions(
193 tools
, [config
.flang_llvm_tools_dir
, config
.llvm_tools_dir
]
196 llvm_config
.add_tool_substitutions(tools
, config
.llvm_tools_dir
)
198 # Enable libpgmath testing
199 result
= lit_config
.params
.get("LIBPGMATH")
201 config
.environment
["LIBPGMATH"] = True
203 # Determine if OpenMP runtime was built (enable OpenMP tests via REQUIRES in test file)
204 if config
.have_openmp_rtl
:
205 config
.available_features
.add("openmp_runtime")
206 # For the enabled OpenMP tests, add a substitution that is needed in the tests to find
207 # the omp_lib.{h,mod} files, depending on whether the OpenMP runtime was built as a
208 # project or runtime.
209 if config
.openmp_module_dir
:
210 config
.substitutions
.append(
211 ("%openmp_flags", f
"-fopenmp -J {config.openmp_module_dir}")
214 config
.substitutions
.append(("%openmp_flags", "-fopenmp"))
216 # Add features and substitutions to test F128 math support.
217 # %f128-lib substitution may be used to generate check prefixes
218 # for LIT tests checking for F128 library support.
219 if config
.flang_runtime_f128_math_lib
or config
.have_ldbl_mant_dig_113
:
220 config
.available_features
.add("flang-supports-f128-math")
221 if config
.flang_runtime_f128_math_lib
:
222 config
.available_features
.add(
223 "flang-f128-math-lib-" + config
.flang_runtime_f128_math_lib
225 config
.substitutions
.append(
226 ("%f128-lib", config
.flang_runtime_f128_math_lib
.upper())
229 config
.substitutions
.append(("%f128-lib", "NONE"))