| 1 |
# -*- Python -*- |
| 2 |
|
| 3 |
import lit.formats |
| 4 |
import lit.util |
| 5 |
|
| 6 |
from lit.llvm import llvm_config |
| 7 |
from lit.llvm.subst import ToolSubst |
| 8 |
from lit.llvm.subst import FindTool |
| 9 |
|
| 10 |
# Configuration file for the 'lit' test runner. |
| 11 |
|
| 12 |
# name: The name of this test suite. |
| 13 |
config.name = 'LLVM_SPIRV' |
| 14 |
|
| 15 |
# testFormat: The test format to use to interpret tests. |
| 16 |
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) |
| 17 |
|
| 18 |
# suffixes: A list of file extensions to treat as test files. |
| 19 |
config.suffixes = ['.cl', '.ll', '.spt', '.spvasm'] |
| 20 |
|
| 21 |
# excludes: A list of directories and fles to exclude from the testsuite. |
| 22 |
config.excludes = ['CMakeLists.txt'] |
| 23 |
|
| 24 |
if config.spirv_tools_found: |
| 25 |
config.available_features.add('libspirv_dis') |
| 26 |
|
| 27 |
if not config.spirv_skip_debug_info_tests: |
| 28 |
# Direct object generation. |
| 29 |
config.available_features.add('object-emission') |
| 30 |
|
| 31 |
# LLVM can be configured with an empty default triple. |
| 32 |
# Some tests are "generic" and require a valid default triple. |
| 33 |
if config.target_triple: |
| 34 |
config.available_features.add('default_triple') |
| 35 |
|
| 36 |
# Ask llvm-config about asserts. |
| 37 |
llvm_config.feature_config([('--assertion-mode', {'ON': 'asserts'})]) |
| 38 |
|
| 39 |
# test_source_root: The root path where tests are located. |
| 40 |
config.test_source_root = os.path.dirname(__file__) |
| 41 |
|
| 42 |
# test_exec_root: The root path where tests should be run. |
| 43 |
config.test_exec_root = os.path.join(config.test_run_dir, 'test_output') |
| 44 |
|
| 45 |
llvm_config.use_default_substitutions() |
| 46 |
|
| 47 |
# Explicitly set `use_installed` to alleviate downstream CI pipelines of |
| 48 |
# any additional environment setup for pre-installed Clang usage. |
| 49 |
llvm_config.use_clang(use_installed=True) |
| 50 |
|
| 51 |
config.substitutions.append(('%PATH%', config.environment['PATH'])) |
| 52 |
|
| 53 |
tool_dirs = [config.llvm_spirv_dir, config.llvm_tools_dir] |
| 54 |
|
| 55 |
tools = ['llvm-as', 'llvm-dis', 'llvm-spirv', 'not'] |
| 56 |
if not config.spirv_skip_debug_info_tests: |
| 57 |
tools.extend(['llc', 'llvm-dwarfdump', 'llvm-objdump', 'llvm-readelf', 'llvm-readobj']) |
| 58 |
|
| 59 |
llvm_config.add_tool_substitutions(tools, tool_dirs) |
| 60 |
|
| 61 |
using_spirv_tools = False |
| 62 |
|
| 63 |
if config.spirv_tools_have_spirv_as: |
| 64 |
llvm_config.add_tool_substitutions(['spirv-as'], [config.spirv_tools_bin_dir]) |
| 65 |
config.available_features.add('spirv-as') |
| 66 |
using_spirv_tools = True |
| 67 |
|
| 68 |
if config.spirv_tools_have_spirv_link: |
| 69 |
llvm_config.add_tool_substitutions(['spirv-link'], [config.spirv_tools_bin_dir]) |
| 70 |
config.available_features.add('spirv-link') |
| 71 |
using_spirv_tools = True |
| 72 |
|
| 73 |
if config.spirv_tools_have_spirv_val: |
| 74 |
llvm_config.add_tool_substitutions(['spirv-val'], [config.spirv_tools_bin_dir]) |
| 75 |
using_spirv_tools = True |
| 76 |
else: |
| 77 |
config.substitutions.append(('spirv-val', ':')) |
| 78 |
|
| 79 |
if using_spirv_tools: |
| 80 |
llvm_config.with_system_environment('LD_LIBRARY_PATH') |
| 81 |
llvm_config.with_environment('LD_LIBRARY_PATH', config.spirv_tools_lib_dir, append_path=True) |