more progress on test/CMakeLists.txt

This commit is contained in:
Yan Da
2022-06-10 21:37:56 +08:00
parent 0ee6e486f8
commit 22c65a53d9
4 changed files with 114 additions and 0 deletions

View File

@@ -207,3 +207,5 @@ if(BUILD_PYTHON_MODULE AND NOT WIN32)
endif() endif()
target_link_libraries(triton ${CUTLASS_LIBRARIES} ${PYTHON_LDFLAGS}) target_link_libraries(triton ${CUTLASS_LIBRARIES} ${PYTHON_LDFLAGS})
endif() endif()
add_subdirectory(test)

23
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,23 @@
llvm_canonicalize_cmake_booleans(
MLIR_ENABLE_BINDINGS_PYTHON
)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCe_DIR}/lit.cfg.py
)
set(TRITON_TEST_DEPENDS
FileCheck count not
triton-opt
)
add_lit_testsuite(check-triton "Running the triton regression tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${STANDALONE_TEST_DEPENDS}
)
set_target_properties(check-triton PROPERTIES FOLDER "Tests")
add_lit_testsuites(TRITON ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${TRITON_TEST_DEPENDS})

66
test/lit.cfg.py Normal file
View File

@@ -0,0 +1,66 @@
# -*- Python -*-
import os
import platform
import re
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
config.name = 'TRITON'
config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.mlir']
# 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.
config.test_exec_root = os.path.join(config.triton_obj_root, 'test')
config.substitutions.append(('%PATH%', config.environment['PATH']))
config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
llvm_config.with_system_environment(
['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])
# 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', 'Examples', '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.
config.test_exec_root = os.path.join(config.triton_obj_root, 'test')
config.triton_tools_dir = os.path.join(config.triton_obj_root, 'bin')
# Tweak the PATH to include the tools dir.
llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
tool_dirs = [config.triton_tools_dir, config.llvm_tools_dir]
tools = [
'triton-opt',
ToolSubst('%PYTHON', config.python_executable, unresolved='ignore'),
]
llvm_config.add_tool_substitutions(tools, tool_dirs)
# TODO: what's this?
llvm_config.with_environment('PYTHONPATH', [
os.path.join(config.mlir_binary_dir, 'python_packages', 'triton'),
], append_path=True)

23
test/lit.site.cfg.py.in Normal file
View File

@@ -0,0 +1,23 @@
@LIT_SITE_CFG_IN_HEADER@
import sys
config.triton_obj_root = "@TRITON_BINARY_DIR@"
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
config.llvm_shlib_dir = "@SHLIBDIR@"
config.llvm_shlib_ext = "@SHLIBEXT@"
config.llvm_exe_ext = "@EXEEXT@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.mlir_binary_dir = "@MLIR_BINARY_DIR@"
config.python_executable = "@Python3_EXECUTABLE@"
config.enable_bindings_python = @MLIR_ENABLE_BINDINGS_PYTHON@
import lit.llvm
lit.llvminitialize(lit_config, config)
# Let the main config do the real work
lit_config.load_config(config, "@TRITON_SOURCE_DIR@/test/lit.cfg.py")