spirv: Remove AssembleFailure() tests
These really test spirv-val, and by relying on its output, often fail when we upgrade spirv-tools. Change-Id: I146a2bf517328b5ef1945247c9ce0b1094ff6122 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86044 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
c990b3c867
commit
bb19d4a24b
|
@ -262,25 +262,6 @@ TEST_F(SpvParserMemoryTest,
|
|||
EXPECT_THAT(got, HasSubstr(expected));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserMemoryTest, EmitStatement_AccessChain_NoOperands) {
|
||||
auto err = test::AssembleFailure(Preamble() + R"(
|
||||
%void = OpTypeVoid
|
||||
%voidfn = OpTypeFunction %void
|
||||
%ty = OpTypeInt 32 0
|
||||
%val = OpConstant %ty 42
|
||||
%ptr_ty = OpTypePointer Private %ty
|
||||
%1 = OpVariable %ptr_ty Private
|
||||
%100 = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
|
||||
%2 = OpAccessChain %ptr_ty ; Needs a base operand
|
||||
OpStore %1 %val
|
||||
OpReturn
|
||||
)");
|
||||
EXPECT_THAT(err,
|
||||
Eq("16:5: Expected operand, found next instruction instead."));
|
||||
}
|
||||
|
||||
TEST_F(SpvParserMemoryTest, EmitStatement_AccessChain_BaseIsNotPointer) {
|
||||
auto p = parser(test::Assemble(Preamble() + R"(
|
||||
%void = OpTypeVoid
|
||||
|
|
|
@ -2571,38 +2571,6 @@ TEST_F(SpvParserHandleTest, ImageWrite_TooFewSrcTexelComponents_1_vs_4) {
|
|||
<< p->error();
|
||||
}
|
||||
|
||||
TEST_F(SpvParserHandleTest, ImageWrite_ThreeComponentStorageTexture_IsError) {
|
||||
// SPIR-V doesn't allow a 3-element storage texture format.
|
||||
const auto assembly = Preamble() + R"(
|
||||
OpEntryPoint Fragment %main "main"
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpName %vf123 "vf123"
|
||||
OpName %coords12 "coords12"
|
||||
OpDecorate %20 DescriptorSet 2
|
||||
OpDecorate %20 Binding 1
|
||||
)" + CommonBasicTypes() +
|
||||
R"(
|
||||
%im_ty = OpTypeImage %void 2D 0 0 0 2 Rgb32f
|
||||
%ptr_im_ty = OpTypePointer UniformConstant %im_ty
|
||||
|
||||
%20 = OpVariable %ptr_im_ty UniformConstant
|
||||
|
||||
%main = OpFunction %void None %voidfn
|
||||
%entry = OpLabel
|
||||
|
||||
%vf123 = OpCopyObject %v3float %the_vf123
|
||||
|
||||
%coords12 = OpCopyObject %v2float %the_vf12
|
||||
|
||||
%im = OpLoad %im_ty %20
|
||||
OpImageWrite %im %coords12 %vf123
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
auto error = test::AssembleFailure(assembly);
|
||||
EXPECT_THAT(error, HasSubstr("Invalid image format 'Rgb32f'"));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
// The texel operand signedness must match the channel type signedness.
|
||||
// SPIR-V validation checks that.
|
||||
|
|
|
@ -1255,34 +1255,6 @@ TEST_F(SpvModuleScopeVarParserTest, StructUndefInitializer) {
|
|||
p->DeliberatelyInvalidSpirv();
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest,
|
||||
LocationDecoration_MissingOperandWontAssemble) {
|
||||
const auto assembly = Preamble() + FragMain() + R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar Location
|
||||
)" + CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Input %uint
|
||||
%myvar = OpVariable %ptr Input
|
||||
)" + MainBody();
|
||||
EXPECT_THAT(test::AssembleFailure(assembly),
|
||||
Eq("10:4: Expected operand, found next instruction instead."));
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest,
|
||||
LocationDecoration_TwoOperandsWontAssemble) {
|
||||
const auto assembly = Preamble() + FragMain() + R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar Location 3 4
|
||||
)" + CommonTypes() + R"(
|
||||
%ptr = OpTypePointer Input %uint
|
||||
%myvar = OpVariable %ptr Input
|
||||
)" + MainBody();
|
||||
EXPECT_THAT(
|
||||
test::AssembleFailure(assembly),
|
||||
Eq("8:34: Expected <opcode> or <result-id> at the beginning of an "
|
||||
"instruction, found '4'."));
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest, DescriptorGroupDecoration_Valid) {
|
||||
auto p = parser(test::Assemble(Preamble() + FragMain() + CommonLayout() + R"(
|
||||
OpDecorate %1 DescriptorSet 3
|
||||
|
@ -1302,36 +1274,6 @@ TEST_F(SpvModuleScopeVarParserTest, DescriptorGroupDecoration_Valid) {
|
|||
<< module_str;
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest,
|
||||
DescriptorGroupDecoration_MissingOperandWontAssemble) {
|
||||
const auto assembly = Preamble() + FragMain() + CommonLayout() + R"(
|
||||
OpDecorate %1 DescriptorSet
|
||||
OpDecorate %strct Block
|
||||
)" + CommonTypes() + StructTypes() +
|
||||
R"(
|
||||
%ptr_sb_strct = OpTypePointer StorageBuffer %strct
|
||||
%1 = OpVariable %ptr_sb_strct StorageBuffer
|
||||
)" + MainBody();
|
||||
EXPECT_THAT(test::AssembleFailure(assembly),
|
||||
Eq("13:5: Expected operand, found next instruction instead."));
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest,
|
||||
DescriptorGroupDecoration_TwoOperandsWontAssemble) {
|
||||
const auto assembly = Preamble() + FragMain() + R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar DescriptorSet 3 4
|
||||
OpDecorate %strct Block
|
||||
)" + CommonTypes() + StructTypes() +
|
||||
R"(
|
||||
%ptr_sb_strct = OpTypePointer StorageBuffer %strct
|
||||
%myvar = OpVariable %ptr_sb_strct StorageBuffer
|
||||
)" + MainBody();
|
||||
EXPECT_THAT(
|
||||
test::AssembleFailure(assembly),
|
||||
Eq("8:39: Expected <opcode> or <result-id> at the beginning of an "
|
||||
"instruction, found '4'."));
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest, BindingDecoration_Valid) {
|
||||
auto p = parser(test::Assemble(Preamble() + FragMain() + R"(
|
||||
|
@ -1353,37 +1295,6 @@ TEST_F(SpvModuleScopeVarParserTest, BindingDecoration_Valid) {
|
|||
<< module_str;
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest,
|
||||
BindingDecoration_MissingOperandWontAssemble) {
|
||||
const auto assembly = Preamble() + FragMain() + R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar Binding
|
||||
OpDecorate %strct Block
|
||||
)" + CommonTypes() + StructTypes() +
|
||||
R"(
|
||||
%ptr_sb_strct = OpTypePointer StorageBuffer %strct
|
||||
%myvar = OpVariable %ptr_sb_strct StorageBuffer
|
||||
)" + MainBody();
|
||||
EXPECT_THAT(test::AssembleFailure(assembly),
|
||||
Eq("9:5: Expected operand, found next instruction instead."));
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest, BindingDecoration_TwoOperandsWontAssemble) {
|
||||
const auto assembly = Preamble() + FragMain() + R"(
|
||||
OpName %myvar "myvar"
|
||||
OpDecorate %myvar Binding 3 4
|
||||
OpDecorate %strct Block
|
||||
)" + CommonTypes() + StructTypes() +
|
||||
R"(
|
||||
%ptr_sb_strct = OpTypePointer StorageBuffer %strct
|
||||
%myvar = OpVariable %ptr_sb_strct StorageBuffer
|
||||
)" + MainBody();
|
||||
EXPECT_THAT(
|
||||
test::AssembleFailure(assembly),
|
||||
Eq("8:33: Expected <opcode> or <result-id> at the beginning of an "
|
||||
"instruction, found '4'."));
|
||||
}
|
||||
|
||||
TEST_F(SpvModuleScopeVarParserTest,
|
||||
StructMember_NonReadableDecoration_Dropped) {
|
||||
auto p = parser(test::Assemble(Preamble() + FragMain() + R"(
|
||||
|
|
|
@ -43,26 +43,6 @@ std::vector<uint32_t> Assemble(const std::string& spirv_assembly) {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string AssembleFailure(const std::string& spirv_assembly) {
|
||||
// TODO(dneto): Use ScopedTrace?
|
||||
|
||||
// (The target environment doesn't affect assembly.
|
||||
spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_0);
|
||||
std::stringstream errors;
|
||||
std::vector<uint32_t> result;
|
||||
tools.SetMessageConsumer([&errors](spv_message_level_t, const char*,
|
||||
const spv_position_t& position,
|
||||
const char* message) {
|
||||
errors << position.line << ":" << position.column << ": " << message;
|
||||
});
|
||||
|
||||
const auto success = tools.Assemble(
|
||||
spirv_assembly, &result, SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
EXPECT_FALSE(success);
|
||||
|
||||
return errors.str();
|
||||
}
|
||||
|
||||
std::string Disassemble(const std::vector<uint32_t>& spirv_module) {
|
||||
spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_0);
|
||||
std::stringstream errors;
|
||||
|
|
|
@ -28,11 +28,6 @@ namespace test {
|
|||
/// are preserved.
|
||||
std::vector<uint32_t> Assemble(const std::string& spirv_assembly);
|
||||
|
||||
/// Attempts to assemble given SPIR-V assembly text. Expect it to fail.
|
||||
/// @param spirv_assembly the SPIR-V assembly
|
||||
/// @returns the failure message.
|
||||
std::string AssembleFailure(const std::string& spirv_assembly);
|
||||
|
||||
/// @param spirv_module a SPIR-V binary module
|
||||
/// @returns the disassembled module
|
||||
std::string Disassemble(const std::vector<uint32_t>& spirv_module);
|
||||
|
|
Loading…
Reference in New Issue