2020-03-06 07:16:55 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import re
|
2020-10-31 04:12:15 +08:00
|
|
|
import shutil
|
2020-03-06 07:16:55 +08:00
|
|
|
import subprocess
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
import lit.formats
|
|
|
|
import lit.util
|
|
|
|
|
|
|
|
from lit.llvm import llvm_config
|
|
|
|
from lit.llvm.subst import ToolSubst
|
|
|
|
from lit.llvm.subst import FindTool
|
|
|
|
|
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
|
|
|
|
# name: The name of this test suite.
|
2020-06-18 01:19:08 +08:00
|
|
|
config.name = 'CIRCT'
|
2020-03-06 07:16:55 +08:00
|
|
|
|
|
|
|
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
|
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
2020-10-31 04:12:15 +08:00
|
|
|
config.suffixes = ['.td', '.mlir', '.ll', '.fir', '.sv']
|
2020-03-06 07:16:55 +08:00
|
|
|
|
|
|
|
# test_source_root: The root path where tests are located.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
# test_exec_root: The root path where tests should be run.
|
2020-06-18 01:19:08 +08:00
|
|
|
config.test_exec_root = os.path.join(config.circt_obj_root, 'test')
|
2020-03-06 07:16:55 +08:00
|
|
|
|
|
|
|
config.substitutions.append(('%PATH%', config.environment['PATH']))
|
|
|
|
config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
|
2021-03-19 22:10:36 +08:00
|
|
|
config.substitutions.append(('%shlibdir', config.circt_shlib_dir))
|
2020-03-06 07:16:55 +08:00
|
|
|
|
2021-04-22 05:13:25 +08:00
|
|
|
llvm_config.with_system_environment(['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])
|
2020-03-06 07:16:55 +08:00
|
|
|
|
|
|
|
llvm_config.use_default_substitutions()
|
|
|
|
|
|
|
|
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
|
|
|
|
# subdirectories contain auxiliary inputs for various tests in their parent
|
|
|
|
# directories.
|
|
|
|
config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
|
|
|
|
|
|
|
|
# test_source_root: The root path where tests are located.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
# test_exec_root: The root path where tests should be run.
|
2020-06-18 01:19:08 +08:00
|
|
|
config.test_exec_root = os.path.join(config.circt_obj_root, 'test')
|
2020-03-06 07:16:55 +08:00
|
|
|
|
|
|
|
# Tweak the PATH to include the tools dir.
|
|
|
|
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
|
|
|
|
|
2021-04-22 05:13:25 +08:00
|
|
|
tool_dirs = [
|
|
|
|
config.circt_tools_dir, config.mlir_tools_dir, config.llvm_tools_dir
|
|
|
|
]
|
2020-03-06 07:16:55 +08:00
|
|
|
tools = [
|
2021-04-22 05:13:25 +08:00
|
|
|
'firtool', 'handshake-runner', 'circt-opt', 'circt-translate',
|
|
|
|
'circt-capi-ir-test', 'esi-tester', 'llhd-sim'
|
2020-03-06 07:16:55 +08:00
|
|
|
]
|
|
|
|
|
2020-10-31 04:12:15 +08:00
|
|
|
# Enable Verilator if it has been detected.
|
|
|
|
if config.verilator_path != "":
|
|
|
|
tool_dirs.append(os.path.dirname(config.verilator_path))
|
|
|
|
tools.append('verilator')
|
|
|
|
config.available_features.add('verilator')
|
|
|
|
|
2020-12-31 15:20:03 +08:00
|
|
|
# Enable ESI's Capnp tests if they're supported.
|
|
|
|
if config.esi_capnp != "":
|
|
|
|
config.available_features.add('capnp')
|
|
|
|
|
2020-03-06 07:16:55 +08:00
|
|
|
llvm_config.add_tool_substitutions(tools, tool_dirs)
|