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 # For each occurrence of a flang tool name, replace it with the full path to
122 # the build directory holding that tool.
124 ToolSubst("%flang", command
=FindTool("flang-new"), unresolved
="fatal"),
127 command
=FindTool("flang-new"),
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
:
141 "%not_todo_abort_cmd",
142 command
=FindTool("not"),
143 extra_args
=["--crash"],
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.
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")
161 os
.path
.isfile(libruntime
)
162 and os
.path
.isfile(libdecimal
)
163 and os
.path
.isdir(include
)
165 config
.available_features
.add("c-compiler")
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
176 if config
.flang_standalone_build
:
177 llvm_config
.add_tool_substitutions(
178 tools
, [config
.flang_llvm_tools_dir
, config
.llvm_tools_dir
]
181 llvm_config
.add_tool_substitutions(tools
, config
.llvm_tools_dir
)
183 # Enable libpgmath testing
184 result
= lit_config
.params
.get("LIBPGMATH")
186 config
.environment
["LIBPGMATH"] = True