Modify testing to only record validation pass/fail
* Changed unit tests to only record known the validation pass/fail status * errors are output as part of the failure message if the result is unexpected * can turn off validation for each test individually * Moved some SPV_KHR_vulkan_memory_model tests to be compiled for Vulkan 1.1
This commit is contained in:
@@ -51,6 +51,7 @@ TEST_P(ConfigTest, FromFile)
|
||||
{
|
||||
TestCaseSpec testCase = GetParam();
|
||||
GlslangResult result;
|
||||
result.validationResult = true;
|
||||
|
||||
// Get the contents for input shader and limit configurations.
|
||||
std::string shaderContents, configContents;
|
||||
|
||||
@@ -77,17 +77,16 @@ TEST_P(LinkTestVulkan, FromFile)
|
||||
if (success && (controls & EShMsgSpvRules)) {
|
||||
spv::SpvBuildLogger logger;
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
glslang::SpvOptions options;
|
||||
options.disableOptimizer = true;
|
||||
options.validate = true;
|
||||
options().disableOptimizer = true;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(shaders.front()->getStage()),
|
||||
spirv_binary, &logger, &options);
|
||||
spirv_binary, &logger, &options());
|
||||
|
||||
std::ostringstream disassembly_stream;
|
||||
spv::Parameterize();
|
||||
spv::Disassemble(disassembly_stream, spirv_binary);
|
||||
result.spirvWarningsErrors = logger.getAllMessages();
|
||||
result.spirv = disassembly_stream.str();
|
||||
result.validationResult = !options().validate || logger.getAllMessages().empty();
|
||||
}
|
||||
|
||||
std::ostringstream stream;
|
||||
@@ -99,7 +98,8 @@ TEST_P(LinkTestVulkan, FromFile)
|
||||
std::string expectedOutput;
|
||||
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
|
||||
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname);
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname,
|
||||
result.spirvWarningsErrors);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
||||
@@ -50,6 +50,7 @@ TEST_P(LinkTest, FromFile)
|
||||
const size_t fileCount = fileNames.size();
|
||||
const EShMessages controls = DeriveOptions(Source::GLSL, Semantics::OpenGL, Target::AST);
|
||||
GlslangResult result;
|
||||
result.validationResult = true;
|
||||
|
||||
// Compile each input shader file.
|
||||
std::vector<std::unique_ptr<glslang::TShader>> shaders;
|
||||
|
||||
@@ -111,7 +111,10 @@ public:
|
||||
: defaultVersion(100),
|
||||
defaultProfile(ENoProfile),
|
||||
forceVersionProfile(false),
|
||||
isForwardCompatible(false) {}
|
||||
isForwardCompatible(false) {
|
||||
// Perform validation by default.
|
||||
validatorOptions.validate = true;
|
||||
}
|
||||
|
||||
// Tries to load the contents from the file at the given |path|. On success,
|
||||
// writes the contents into |contents|. On failure, errors out.
|
||||
@@ -137,15 +140,18 @@ public:
|
||||
// write |real| to the given file named as |fname| if update mode is on.
|
||||
void checkEqAndUpdateIfRequested(const std::string& expected,
|
||||
const std::string& real,
|
||||
const std::string& fname)
|
||||
const std::string& fname,
|
||||
const std::string& errorsAndWarnings = "")
|
||||
{
|
||||
// In order to output the message we want under proper circumstances,
|
||||
// we need the following operator<< stuff.
|
||||
EXPECT_EQ(expected, real)
|
||||
<< (GlobalTestSettings.updateMode
|
||||
? ("Mismatch found and update mode turned on - "
|
||||
"flushing expected result output.")
|
||||
: "");
|
||||
"flushing expected result output.\n")
|
||||
: "")
|
||||
<< "The following warnings/errors occurred:\n"
|
||||
<< errorsAndWarnings;
|
||||
|
||||
// Update the expected output file if requested.
|
||||
// It looks weird to duplicate the comparison between expected_output
|
||||
@@ -168,6 +174,7 @@ public:
|
||||
std::vector<ShaderResult> shaderResults;
|
||||
std::string linkingOutput;
|
||||
std::string linkingError;
|
||||
bool validationResult;
|
||||
std::string spirvWarningsErrors;
|
||||
std::string spirv; // Optional SPIR-V disassembly text.
|
||||
};
|
||||
@@ -241,21 +248,20 @@ public:
|
||||
|
||||
if (success && (controls & EShMsgSpvRules)) {
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
glslang::SpvOptions options;
|
||||
options.disableOptimizer = !enableOptimizer;
|
||||
options.validate = true;
|
||||
options().disableOptimizer = !enableOptimizer;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage),
|
||||
spirv_binary, &logger, &options);
|
||||
spirv_binary, &logger, &options());
|
||||
|
||||
std::ostringstream disassembly_stream;
|
||||
spv::Parameterize();
|
||||
spv::Disassemble(disassembly_stream, spirv_binary);
|
||||
bool validation_result = !options().validate || logger.getAllMessages().empty();
|
||||
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
|
||||
program.getInfoLog(), program.getInfoDebugLog(),
|
||||
logger.getAllMessages(), disassembly_stream.str()};
|
||||
validation_result, logger.getAllMessages(), disassembly_stream.str()};
|
||||
} else {
|
||||
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
|
||||
program.getInfoLog(), program.getInfoDebugLog(), "", ""};
|
||||
program.getInfoLog(), program.getInfoDebugLog(), true, "", ""};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,20 +305,19 @@ public:
|
||||
|
||||
if (success && (controls & EShMsgSpvRules)) {
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
glslang::SpvOptions options;
|
||||
options.validate = true;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage),
|
||||
spirv_binary, &logger, &options);
|
||||
spirv_binary, &logger, &options());
|
||||
|
||||
std::ostringstream disassembly_stream;
|
||||
spv::Parameterize();
|
||||
spv::Disassemble(disassembly_stream, spirv_binary);
|
||||
bool validation_result = !options().validate || logger.getAllMessages().empty();
|
||||
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
|
||||
program.getInfoLog(), program.getInfoDebugLog(),
|
||||
logger.getAllMessages(), disassembly_stream.str()};
|
||||
validation_result, logger.getAllMessages(), disassembly_stream.str()};
|
||||
} else {
|
||||
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
|
||||
program.getInfoLog(), program.getInfoDebugLog(), "", ""};
|
||||
program.getInfoLog(), program.getInfoDebugLog(), true, "", ""};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,22 +346,21 @@ public:
|
||||
|
||||
if (success && (controls & EShMsgSpvRules)) {
|
||||
std::vector<uint32_t> spirv_binary;
|
||||
glslang::SpvOptions options;
|
||||
options.validate = true;
|
||||
glslang::GlslangToSpv(*program.getIntermediate(stage),
|
||||
spirv_binary, &logger, &options);
|
||||
spirv_binary, &logger, &options());
|
||||
|
||||
spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions);
|
||||
|
||||
std::ostringstream disassembly_stream;
|
||||
spv::Parameterize();
|
||||
spv::Disassemble(disassembly_stream, spirv_binary);
|
||||
bool validation_result = !options().validate || logger.getAllMessages().empty();
|
||||
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
|
||||
program.getInfoLog(), program.getInfoDebugLog(),
|
||||
logger.getAllMessages(), disassembly_stream.str()};
|
||||
validation_result, logger.getAllMessages(), disassembly_stream.str()};
|
||||
} else {
|
||||
return {{{shaderName, shader.getInfoLog(), shader.getInfoDebugLog()},},
|
||||
program.getInfoLog(), program.getInfoDebugLog(), "", ""};
|
||||
program.getInfoLog(), program.getInfoDebugLog(), true, "", ""};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,9 +381,9 @@ public:
|
||||
|
||||
return {{{shaderName, "", ""},},
|
||||
"", "",
|
||||
"", disassembly_stream.str()};
|
||||
true, "", disassembly_stream.str()};
|
||||
} else {
|
||||
return {{{shaderName, "", ""},}, "", "", "", ""};
|
||||
return {{{shaderName, "", ""},}, "", "", true, "", ""};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,7 +402,9 @@ public:
|
||||
}
|
||||
outputIfNotEmpty(result.linkingOutput);
|
||||
outputIfNotEmpty(result.linkingError);
|
||||
*stream << result.spirvWarningsErrors;
|
||||
if (!result.validationResult) {
|
||||
*stream << "Validation failed\n";
|
||||
}
|
||||
|
||||
if (controls & EShMsgSpvRules) {
|
||||
*stream
|
||||
@@ -438,7 +444,7 @@ public:
|
||||
outputResultToStream(&stream, result, controls);
|
||||
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
|
||||
expectedOutputFname);
|
||||
expectedOutputFname, result.spirvWarningsErrors);
|
||||
}
|
||||
|
||||
void loadFileCompileFlattenUniformsAndCheck(const std::string& testDir,
|
||||
@@ -465,7 +471,7 @@ public:
|
||||
outputResultToStream(&stream, result, controls);
|
||||
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
|
||||
expectedOutputFname);
|
||||
expectedOutputFname, result.spirvWarningsErrors);
|
||||
}
|
||||
|
||||
void loadFileCompileIoMapAndCheck(const std::string& testDir,
|
||||
@@ -502,7 +508,7 @@ public:
|
||||
outputResultToStream(&stream, result, controls);
|
||||
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
|
||||
expectedOutputFname);
|
||||
expectedOutputFname, result.spirvWarningsErrors);
|
||||
}
|
||||
|
||||
void loadFileCompileRemapAndCheck(const std::string& testDir,
|
||||
@@ -529,7 +535,7 @@ public:
|
||||
outputResultToStream(&stream, result, controls);
|
||||
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
|
||||
expectedOutputFname);
|
||||
expectedOutputFname, result.spirvWarningsErrors);
|
||||
}
|
||||
|
||||
void loadFileRemapAndCheck(const std::string& testDir,
|
||||
@@ -556,7 +562,7 @@ public:
|
||||
outputResultToStream(&stream, result, controls);
|
||||
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
|
||||
expectedOutputFname);
|
||||
expectedOutputFname, result.spirvWarningsErrors);
|
||||
}
|
||||
|
||||
// Preprocesses the given |source| code. On success, returns true, the
|
||||
@@ -636,14 +642,17 @@ public:
|
||||
outputResultToStream(&stream, result, controls);
|
||||
|
||||
checkEqAndUpdateIfRequested(expectedOutput, stream.str(),
|
||||
expectedOutputFname);
|
||||
expectedOutputFname, result.spirvWarningsErrors);
|
||||
}
|
||||
|
||||
glslang::SpvOptions& options() { return validatorOptions; }
|
||||
|
||||
private:
|
||||
const int defaultVersion;
|
||||
const EProfile defaultProfile;
|
||||
const bool forceVersionProfile;
|
||||
const bool isForwardCompatible;
|
||||
glslang::SpvOptions validatorOptions;
|
||||
};
|
||||
|
||||
} // namespace glslangtest
|
||||
|
||||
Reference in New Issue
Block a user