diff --git a/test_conformance/spirv_new/main.cpp b/test_conformance/spirv_new/main.cpp index 21a42423..0f801092 100644 --- a/test_conformance/spirv_new/main.cpp +++ b/test_conformance/spirv_new/main.cpp @@ -31,6 +31,8 @@ const std::string slash = "/"; const std::string spvExt = ".spv"; std::string gAddrWidth = ""; +std::string spvBinariesPath = "spirv_bin"; +std::string spvBinariesPathArg = "--spirv-binaries-path"; std::vector readBinary(const char *file_name) { @@ -58,7 +60,7 @@ std::vector readBinary(const char *file_name) std::vector readSPIRV(const char *file_name) { - std::string full_name_str = gCompilationCachePath + slash + file_name + spvExt + gAddrWidth; + std::string full_name_str = spvBinariesPath + slash + file_name + spvExt + gAddrWidth; return readBinary(full_name_str.c_str()); } @@ -97,7 +99,7 @@ static int offline_get_program_with_il(clProgramWrapper &prog, cl_int err = 0; std::string outputTypeStr = "binary"; std::string defaultScript = std::string("..") + slash + std::string("spv_to_binary.py"); - std::string outputFilename = gCompilationCachePath + slash + std::string(prog_name); + std::string outputFilename = spvBinariesPath + slash + std::string(prog_name); std::string sourceFilename = outputFilename + spvExt; std::string scriptArgs = @@ -174,9 +176,40 @@ test_status checkAddressWidth(cl_device_id id) return TEST_PASS; } +void printUsage() { + log_info("Reading SPIR-V files from default '%s' path.\n", spvBinariesPath.c_str()); + log_info("In case you want to set other directory use '%s' argument.\n", spvBinariesPathArg.c_str()); +} + int main(int argc, const char *argv[]) { gReSeed = 1; + bool modifiedSpvBinariesPath = false; + for (int i = 0; i < argc; ++i) { + int argsRemoveNum = 0; + if (argv[i] == spvBinariesPathArg) { + if (i + 1 == argc) { + log_error("Missing value for '%s' argument.\n", spvBinariesPathArg.c_str()); + return TEST_FAIL; + } else { + spvBinariesPath = std::string(argv[i + 1]); + argsRemoveNum += 2; + modifiedSpvBinariesPath = true; + } + } + + if (argsRemoveNum > 0) { + for (int j = i; j < (argc - argsRemoveNum); ++j) + argv[j] = argv[j + argsRemoveNum]; + + argc -= argsRemoveNum; + --i; + } + } + if (modifiedSpvBinariesPath == false) { + printUsage(); + } + return runTestHarnessWithCheck(argc, argv, spirvTestsRegistry::getInstance().getNumTests(), spirvTestsRegistry::getInstance().getTestDefinitions(),