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.
28 config
.suffixes
= ['.c', '.cpp', '.f', '.F', '.ff', '.FOR', '.for', '.f77', '.f90', '.F90',
29 '.ff90', '.f95', '.F95', '.ff95', '.fpp', '.FPP', '.cuf'
30 '.CUF', '.f18', '.F18', '.fir', '.f03', '.F03', '.f08', '.F08']
32 config
.substitutions
.append(('%PATH%', config
.environment
['PATH']))
33 config
.substitutions
.append(('%llvmshlibdir', config
.llvm_shlib_dir
))
34 config
.substitutions
.append(('%pluginext', config
.llvm_plugin_ext
))
36 llvm_config
.use_default_substitutions()
38 # ask llvm-config about asserts
39 llvm_config
.feature_config(
40 [('--assertion-mode', {'ON': 'asserts'})])
43 config
.targets
= frozenset(config
.targets_to_build
.split())
44 for arch
in config
.targets_to_build
.split():
45 config
.available_features
.add(arch
.lower() + '-registered-target')
47 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
48 # subdirectories contain auxiliary inputs for various tests in their parent
50 config
.excludes
= ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
52 # If the flang examples are built, add examples to the config
53 if config
.flang_examples
:
54 config
.available_features
.add('examples')
56 # Plugins (loadable modules)
57 if config
.has_plugins
:
58 config
.available_features
.add('plugins')
60 # test_source_root: The root path where tests are located.
61 config
.test_source_root
= os
.path
.dirname(__file__
)
63 # test_exec_root: The root path where tests should be run.
64 config
.test_exec_root
= os
.path
.join(config
.flang_obj_root
, 'test')
66 # Tweak the PATH to include the tools dir.
67 llvm_config
.with_environment('PATH', config
.flang_tools_dir
, append_path
=True)
68 llvm_config
.with_environment('PATH', config
.llvm_tools_dir
, append_path
=True)
70 if config
.flang_standalone_build
:
71 # For builds with FIR, set path for tco and enable related tests
72 if config
.flang_llvm_tools_dir
!= "":
73 config
.available_features
.add('fir')
74 if config
.llvm_tools_dir
!= config
.flang_llvm_tools_dir
:
75 llvm_config
.with_environment('PATH', config
.flang_llvm_tools_dir
, append_path
=True)
77 # For each occurrence of a flang tool name, replace it with the full path to
78 # the build directory holding that tool.
80 ToolSubst('%flang', command
=FindTool('flang-new'), unresolved
='fatal'),
81 ToolSubst('%flang_fc1', command
=FindTool('flang-new'), extra_args
=['-fc1'],
84 # Flang has several unimplemented features. TODO messages are used to mark and fail if these
85 # features are exercised. TODOs exit with an error in non-assert builds but in assert builds
86 # it aborts. To catch aborts, the `--crash` option for the `not` command has to be used.
87 if 'asserts' in config
.available_features
:
88 tools
.append(ToolSubst('%not_todo_cmd', command
=FindTool('not'), extra_args
=['--crash'],
91 tools
.append(ToolSubst('%not_todo_cmd', command
=FindTool('not'), unresolved
='fatal'))
93 # Define some variables to help us test that the flang runtime doesn't depend on
94 # the C++ runtime libraries. For this we need a C compiler. If for some reason
95 # we don't have one, we can just disable the test.
97 libruntime
= os
.path
.join(config
.flang_lib_dir
, 'libFortranRuntime.a')
98 libdecimal
= os
.path
.join(config
.flang_lib_dir
, 'libFortranDecimal.a')
99 include
= os
.path
.join(config
.flang_src_dir
, 'include')
101 if os
.path
.isfile(libruntime
) and os
.path
.isfile(libdecimal
) and os
.path
.isdir(include
):
102 config
.available_features
.add('c-compiler')
103 tools
.append(ToolSubst('%cc', command
=config
.cc
, unresolved
='fatal'))
104 tools
.append(ToolSubst('%libruntime', command
=libruntime
,
106 tools
.append(ToolSubst('%libdecimal', command
=libdecimal
,
108 tools
.append(ToolSubst('%include', command
=include
,
111 # Add all the tools and their substitutions (if applicable). Use the search paths provided for
113 if config
.flang_standalone_build
:
114 llvm_config
.add_tool_substitutions(tools
, [config
.flang_llvm_tools_dir
, config
.llvm_tools_dir
])
116 llvm_config
.add_tool_substitutions(tools
, config
.llvm_tools_dir
)
118 # Enable libpgmath testing
119 result
= lit_config
.params
.get("LIBPGMATH")
121 config
.environment
["LIBPGMATH"] = True