This test will check the logical layout of a binary by removing each instruction in the pair of the INSTANTIATE_TEST_SUITE_P call and moving it in the SPIRV source formed by combining the vector "instructions".
| 175 | // instruction in the pair of the INSTANTIATE_TEST_SUITE_P call and moving it in |
| 176 | // the SPIRV source formed by combining the vector "instructions". |
| 177 | TEST_P(ValidateLayout, Layout) { |
| 178 | int order; |
| 179 | std::string instruction; |
| 180 | pred_type pred; |
| 181 | pred_type test_pred; // Predicate to determine if the test should be build |
| 182 | std::tuple<std::string, pred_type, pred_type> testCase; |
| 183 | |
| 184 | std::tie(order, testCase) = GetParam(); |
| 185 | std::tie(instruction, pred, test_pred) = testCase; |
| 186 | |
| 187 | // Skip test which break the code generation |
| 188 | if (test_pred(order)) return; |
| 189 | |
| 190 | std::vector<std::string> code = GenerateCode(instruction, order); |
| 191 | |
| 192 | std::stringstream ss; |
| 193 | std::copy(std::begin(code), std::end(code), |
| 194 | std::ostream_iterator<std::string>(ss, "\n")); |
| 195 | |
| 196 | const auto env = SPV_ENV_UNIVERSAL_1_3; |
| 197 | // printf("code: \n%s\n", ss.str().c_str()); |
| 198 | CompileSuccessfully(ss.str(), env); |
| 199 | spv_result_t result; |
| 200 | // clang-format off |
| 201 | ASSERT_EQ(pred(order), result = ValidateInstructions(env)) |
| 202 | << "Actual: " << spvResultToString(result) |
| 203 | << "\nExpected: " << spvResultToString(pred(order)) |
| 204 | << "\nOrder: " << order |
| 205 | << "\nInstruction: " << instruction |
| 206 | << "\nCode: \n" << ss.str(); |
| 207 | // clang-format on |
| 208 | } |
| 209 | |
| 210 | TEST_F(ValidateLayout, MemoryModelMissingBeforeEntryPoint) { |
| 211 | std::string str = R"( |
nothing calls this directly
no test coverage detected