Enable running tests under LIT (#4813)

* Enable running tests under LIT

If `CLANG_INCLUDE_TESTS=On`, the googletest unit tests are built as
part of the clang unit test suite. This allows them to run via lit
using the `check-clang-unit` target.

* Configure DXILConv tests to run under check-all
This commit is contained in:
Chris B 2022-11-29 18:59:16 -06:00 коммит произвёл GitHub
Родитель ea3c096960
Коммит 7d9567cf80
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 45 добавлений и 36 удалений

Просмотреть файл

@ -11,6 +11,15 @@ if (DXC_COVERAGE)
set(LLVM_CODE_COVERAGE_TARGETS "dxc;dxcompiler" CACHE STRING "")
endif()
if (DXC_USE_LIT)
set(LLVM_TEST_VALUE ON)
else()
set(LLVM_TEST_VALUE OFF)
endif()
set(LLVM_INCLUDE_TESTS ${LLVM_TEST_VALUE} CACHE BOOL "")
set(CLANG_INCLUDE_TESTS ${LLVM_TEST_VALUE} CACHE BOOL "")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
set(LLVM_APPEND_VC_REV ON CACHE BOOL "")
set(LLVM_DEFAULT_TARGET_TRIPLE "dxil-ms-dx" CACHE STRING "")
@ -18,7 +27,6 @@ set(LLVM_ENABLE_EH ON CACHE BOOL "")
set(LLVM_ENABLE_RTTI ON CACHE BOOL "")
set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(LLVM_OPTIMIZED_TABLEGEN OFF CACHE BOOL "")
set(LLVM_REQUIRES_EH ON CACHE BOOL "")
set(LLVM_REQUIRES_RTTI ON CACHE BOOL "")
@ -28,7 +36,6 @@ set(CLANG_BUILD_EXAMPLES OFF CACHE BOOL "")
set(CLANG_CL OFF CACHE BOOL "")
set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
set(HLSL_INCLUDE_TESTS ON CACHE BOOL "")
set(ENABLE_SPIRV_CODEGEN ON CACHE BOOL "")
set(SPIRV_BUILD_TESTS ON CACHE BOOL "")

Просмотреть файл

@ -8,7 +8,7 @@ configure_lit_site_cfg(
# HLSL Change Begin - Add taef tests
add_lit_target("check-dxilconv" "Running lit suite dxilconv"
add_lit_testsuite("check-dxilconv" "Running lit suite dxilconv"
${CMAKE_CURRENT_SOURCE_DIR}/taef
PARAMS
dxilconv_site_config=${CMAKE_CURRENT_BINARY_DIR}/taef/lit.site.cfg

Просмотреть файл

@ -5,7 +5,7 @@ import sys
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.build_mode = lit_config.params["build_mode"]
config.arch = "@DXC_BUILD_ARCH@"
config.arch = "@CMAKE_C_COMPILER_ARCHITECTURE_ID@"
# Let the main config do the real work.
lit_config.load_config(config, "@LLVM_SOURCE_DIR@/projects/dxilconv/test/taef/lit.cfg")

Просмотреть файл

@ -9,7 +9,7 @@ import lit.formats
import lit.util
# name: The name of this test suite.
config.name = 'clang-hlsl'
config.name = 'clang-taef'
# Check that the object root is known.
llvm_obj_root = getattr(config, 'llvm_obj_root', None)
@ -28,7 +28,7 @@ if llvm_obj_root is None:
te = os.path.join(config.llvm_obj_root, "TAEF", config.arch, 'te.exe')
test_dll = os.path.join(config.llvm_obj_root, config.build_mode, 'bin', 'clang-hlsl-tests.dll')
test_dll = os.path.join(config.llvm_obj_root, config.build_mode, 'bin', 'ClangHLSLTests.dll')
hlsl_data_dir = os.path.join(config.llvm_src_root, 'tools', 'clang', 'test', 'hlsl')

Просмотреть файл

@ -8,4 +8,4 @@ config.build_mode = lit_config.params["build_mode"]
config.arch = "@DXC_BUILD_ARCH@"
# Let the main config do the real work.
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/clang-hlsl/lit.cfg")
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/taef/lit.cfg")

Просмотреть файл

@ -28,7 +28,7 @@ set(HLSL_IGNORE_SOURCES
TestMain.cpp
HLSLTestOptions.cpp
)
add_clang_library(clang-hlsl-tests SHARED
add_clang_library(ClangHLSLTests SHARED
AllocatorTest.cpp
CompilerTest.cpp
DxilContainerTest.cpp
@ -61,7 +61,7 @@ set(HLSL_IGNORE_SOURCES
ShaderOpTest.cpp
)
add_clang_unittest(clang-hlsl-tests
add_clang_unittest(ClangHLSLTests
AllocatorTest.cpp
CompilerTest.cpp
DxilContainerTest.cpp
@ -82,10 +82,10 @@ add_clang_unittest(clang-hlsl-tests
endif(WIN32)
set_target_properties(clang-hlsl-tests PROPERTIES FOLDER "Clang tests")
set_target_properties(ClangHLSLTests PROPERTIES FOLDER "Clang tests")
if (WIN32)
target_link_libraries(clang-hlsl-tests PRIVATE
target_link_libraries(ClangHLSLTests PRIVATE
dxcompiler
HLSLTestLib
LLVMDxilContainer
@ -96,7 +96,7 @@ target_link_libraries(clang-hlsl-tests PRIVATE
shlwapi
)
else(WIN32)
target_link_libraries(clang-hlsl-tests
target_link_libraries(ClangHLSLTests
dxcompiler
HLSLTestLib
)
@ -113,23 +113,22 @@ endif(WIN32)
# Add includes to directly reference intrinsic tables.
include_directories(${CLANG_BINARY_DIR}/lib/Sema)
add_dependencies(clang-hlsl-tests dxcompiler)
add_dependencies(ClangHLSLTests dxcompiler)
if(WIN32)
install(TARGETS clang-hlsl-tests
RUNTIME DESTINATION bin)
else(WIN32)
set_output_directory(clang-hlsl-tests
${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
endif(WIN32)
if (NOT CLANG_INCLUDE_TESTS)
set_target_properties(ClangHLSLTests PROPERTIES OUTPUT_NAME clang-hlsl-tests)
set_output_directory(ClangHLSLTests
${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
if (NOT WIN32)
add_test(NAME test-hlsl-codegen
COMMAND $<TARGET_FILE:ClangHLSLTests> --HlslDataDir
${PROJECT_SOURCE_DIR}/tools/clang/test/HLSL)
endif()
endif()
if(WIN32)
# Add a .user file with settings for te.exe.
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" DOS_STYLE_SOURCE_DIR)
file(TO_NATIVE_PATH "${TAEF_BIN_DIR}" DOS_TAEF_BIN_DIR)
configure_file(clang-hlsl-tests.vcxproj.user.txt clang-hlsl-tests.vcxproj.user)
configure_file(ClangHLSLTests.vcxproj.user.txt ClangHLSLTests.vcxproj.user)
endif(WIN32)
add_test(NAME test-hlsl-codegen
COMMAND clang-hlsl-tests --HlslDataDir
${PROJECT_SOURCE_DIR}/tools/clang/test/HLSL)

Просмотреть файл

@ -12,14 +12,14 @@ add_clang_executable(HLSLHost
)
target_link_libraries(HLSLHost
clang-hlsl-tests
ClangHLSLTests
)
set_target_properties(HLSLHost PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
add_dependencies(HLSLHost clang-hlsl-tests)
add_dependencies(HLSLHost ClangHLSLTests)
if(UNIX)
set(CLANGXX_LINK_OR_COPY create_symlink)

Просмотреть файл

@ -6,7 +6,7 @@ set(LLVM_LINK_COMPONENTS
hlsl
)
add_clang_unittest(clang-spirv-tests
add_clang_unittest(ClangSPIRVTests
CodeGenSpirvTest.cpp
FileTestFixture.cpp
FileTestUtils.cpp
@ -21,7 +21,7 @@ add_clang_unittest(clang-spirv-tests
WholeFileTestFixture.cpp
)
target_link_libraries(clang-spirv-tests
target_link_libraries(ClangSPIRVTests
clangAST
clangBasic
clangCodeGen
@ -36,13 +36,16 @@ target_link_libraries(clang-spirv-tests
# This is necessary so that the linked dxcompiler is loaded into memory space
# first, and in case dxcompiler.so is loaded via 'dlopen', it resolves to the
# same memory space, and prevents getting two copies of global static variables.
add_dependencies(clang-spirv-tests dxcompiler)
add_dependencies(ClangSPIRVTests dxcompiler)
target_include_directories(clang-spirv-tests
target_include_directories(ClangSPIRVTests
PRIVATE ${SPIRV_TOOLS_INCLUDE_DIR} ${DXC_EFFCEE_DIR})
set_output_directory(clang-spirv-tests
${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
if (NOT CLANG_INCLUDE_TESTS)
set_target_properties(ClangSPIRVTests PROPERTIES OUTPUT_NAME clang-spirv-tests)
set_output_directory(ClangSPIRVTests
${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
endif()
set(SPIRV_TEST_DATA_DIR ${LLVM_SOURCE_DIR}/tools/clang/test/CodeGenSPIRV/)
configure_file(
@ -54,6 +57,6 @@ if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # otherwise will hit fatal error C1128 on windows x64
endif(WIN32)
add_test(NAME test-spirv-codegen
COMMAND clang-spirv-tests --spirv-test-root
${PROJECT_SOURCE_DIR}/tools/clang/test/CodeGenSPIRV)
if (NOT CLANG_INCLUDE_TESTS)
add_test(NAME test-spirv-codegen COMMAND $<TARGET_FILE:ClangSPIRVTests>)
endif()