| 45 | ::testing::TestWithParam<std::vector<std::string>>>; |
| 46 | |
| 47 | TEST_P(LinkTest, FromFile) |
| 48 | { |
| 49 | const auto& fileNames = GetParam(); |
| 50 | const size_t fileCount = fileNames.size(); |
| 51 | const EShMessages controls = DeriveOptions(Source::GLSL, Semantics::OpenGL, Target::AST); |
| 52 | GlslangResult result; |
| 53 | result.validationResult = true; |
| 54 | |
| 55 | // Compile each input shader file. |
| 56 | std::vector<std::unique_ptr<glslang::TShader>> shaders; |
| 57 | for (size_t i = 0; i < fileCount; ++i) { |
| 58 | std::string contents; |
| 59 | tryLoadFile(GlobalTestSettings.testRoot + "/" + fileNames[i], |
| 60 | "input", &contents); |
| 61 | shaders.emplace_back( |
| 62 | new glslang::TShader(GetShaderStage(GetSuffix(fileNames[i])))); |
| 63 | auto* shader = shaders.back().get(); |
| 64 | compile(shader, contents, "", controls); |
| 65 | result.shaderResults.push_back( |
| 66 | {fileNames[i], shader->getInfoLog(), shader->getInfoDebugLog()}); |
| 67 | } |
| 68 | |
| 69 | // Link all of them. |
| 70 | glslang::TProgram program; |
| 71 | for (const auto& shader : shaders) program.addShader(shader.get()); |
| 72 | program.link(controls); |
| 73 | result.linkingOutput = program.getInfoLog(); |
| 74 | result.linkingError = program.getInfoDebugLog(); |
| 75 | |
| 76 | std::ostringstream stream; |
| 77 | outputResultToStream(&stream, result, controls); |
| 78 | |
| 79 | // Check with expected results. |
| 80 | const std::string expectedOutputFname = |
| 81 | GlobalTestSettings.testRoot + "/baseResults/" + fileNames.front() + ".out"; |
| 82 | std::string expectedOutput; |
| 83 | tryLoadFile(expectedOutputFname, "expected output", &expectedOutput); |
| 84 | |
| 85 | checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname); |
| 86 | } |
| 87 | |
| 88 | // clang-format off |
| 89 | INSTANTIATE_TEST_SUITE_P( |
nothing calls this directly
no test coverage detected