|
| 1 | +import os |
| 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 = "libclc" |
| 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 = [ |
| 20 | + ".cl", |
| 21 | +] |
| 22 | + |
| 23 | +# test_source_root: The root path where tests are located. |
| 24 | +config.test_source_root = os.path.join(os.path.dirname(__file__)) |
| 25 | + |
| 26 | +# test_exec_root: The root path where tests should be run. |
| 27 | +config.test_exec_root = os.path.join(config.test_run_dir, "test") |
| 28 | + |
| 29 | +llvm_config.use_default_substitutions() |
| 30 | + |
| 31 | +target = lit_config.params.get("target", "") |
| 32 | +builtins = lit_config.params.get("builtins", "") |
| 33 | + |
| 34 | +clang_flags = [ |
| 35 | + "-fno-builtin", |
| 36 | + "-target", |
| 37 | + target, |
| 38 | + "-Xclang", |
| 39 | + "-mlink-builtin-bitcode", |
| 40 | + "-Xclang", |
| 41 | + os.path.join(config.libclc_lib_dir, builtins), |
| 42 | + "-nogpulib", |
| 43 | +] |
| 44 | + |
| 45 | +cpu = lit_config.params.get("cpu", "") |
| 46 | +if cpu: |
| 47 | + clang_flags.append(f"-mcpu={cpu}") |
| 48 | + |
| 49 | +llvm_config.use_clang(additional_flags=clang_flags) |
| 50 | + |
| 51 | +tools = [ |
| 52 | + "llvm-dis", |
| 53 | + "not", |
| 54 | +] |
| 55 | +tool_dirs = [config.llvm_tools_dir] |
| 56 | + |
| 57 | +llvm_config.add_tool_substitutions(tools, tool_dirs) |
0 commit comments