Skip to content

Commit f12b050

Browse files
authored
Enable SPIR-V tests to run without arguments (#4802)
* Enable SPIR-V tests to run without arguments This specifies a default value for the --spirv-test-root flag based on the source directory at configuration time. This simplifies the command line for running the tests manually, but does not alter the ability to override the test directory explicitly. * Restoring code I should not have deleted
1 parent b0d5211 commit f12b050

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

tools/clang/unittests/SPIRV/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ target_include_directories(clang-spirv-tests
4444
set_output_directory(clang-spirv-tests
4545
${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
4646

47+
set(SPIRV_TEST_DATA_DIR ${LLVM_SOURCE_DIR}/tools/clang/test/CodeGenSPIRV/)
48+
configure_file(
49+
${CMAKE_CURRENT_SOURCE_DIR}/SpirvTestOptions.h.in
50+
${CMAKE_CURRENT_BINARY_DIR}/SpirvTestOptions.h
51+
)
52+
4753
if(WIN32)
4854
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # otherwise will hit fatal error C1128 on windows x64
4955
endif(WIN32)

tools/clang/unittests/SPIRV/SpirvTestOptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace clang {
1818
namespace spirv {
1919
namespace testOptions {
2020

21-
std::string inputDataDir = "";
21+
std::string inputDataDir = DEFAULT_TEST_DIR;
2222

2323
} // namespace testOptions
2424
} // namespace spirv

tools/clang/unittests/SPIRV/SpirvTestOptions.h renamed to tools/clang/unittests/SPIRV/SpirvTestOptions.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#ifndef LLVM_CLANG_UNITTESTS_SPIRV_TEST_OPTIONS_H
1717
#define LLVM_CLANG_UNITTESTS_SPIRV_TEST_OPTIONS_H
1818

19+
#define DEFAULT_TEST_DIR "@SPIRV_TEST_DATA_DIR@"
20+
1921
#include <string>
2022

2123
namespace clang {

0 commit comments

Comments
 (0)