瀏覽代碼

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
Chris B 2 年之前
父節點
當前提交
f12b050405

+ 6 - 0
tools/clang/unittests/SPIRV/CMakeLists.txt

@@ -44,6 +44,12 @@ target_include_directories(clang-spirv-tests
 set_output_directory(clang-spirv-tests
 set_output_directory(clang-spirv-tests
   ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
   ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
 
 
+set(SPIRV_TEST_DATA_DIR ${LLVM_SOURCE_DIR}/tools/clang/test/CodeGenSPIRV/)
+configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/SpirvTestOptions.h.in
+    ${CMAKE_CURRENT_BINARY_DIR}/SpirvTestOptions.h
+    )
+
 if(WIN32)
 if(WIN32)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # otherwise will hit fatal error C1128 on windows x64
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # otherwise will hit fatal error C1128 on windows x64
 endif(WIN32)
 endif(WIN32)

+ 1 - 1
tools/clang/unittests/SPIRV/SpirvTestOptions.cpp

@@ -18,7 +18,7 @@ namespace clang {
 namespace spirv {
 namespace spirv {
 namespace testOptions {
 namespace testOptions {
 
 
-std::string inputDataDir = "";
+std::string inputDataDir = DEFAULT_TEST_DIR;
 
 
 } // namespace testOptions
 } // namespace testOptions
 } // namespace spirv
 } // namespace spirv

+ 2 - 0
tools/clang/unittests/SPIRV/SpirvTestOptions.h → tools/clang/unittests/SPIRV/SpirvTestOptions.h.in

@@ -16,6 +16,8 @@
 #ifndef LLVM_CLANG_UNITTESTS_SPIRV_TEST_OPTIONS_H
 #ifndef LLVM_CLANG_UNITTESTS_SPIRV_TEST_OPTIONS_H
 #define LLVM_CLANG_UNITTESTS_SPIRV_TEST_OPTIONS_H
 #define LLVM_CLANG_UNITTESTS_SPIRV_TEST_OPTIONS_H
 
 
+#define DEFAULT_TEST_DIR "@SPIRV_TEST_DATA_DIR@"
+
 #include <string>
 #include <string>
 
 
 namespace clang {
 namespace clang {