Handle errors in SPIRV-Reader tests.
This CL updates some EXPECT to ASSERT in the spirv-reader tests to work around segvs when tests fail. Bug: tint:1686 Change-Id: Icfd5a83cc71709fd351c3d5a39a9a0173056a0f8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121340 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
107aa81c89
commit
65a45fdf41
|
@ -28,7 +28,7 @@ const char* kSkipReason = "This example is deliberately a SPIR-V fragment";
|
|||
|
||||
TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_NotAnId) {
|
||||
auto p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(42);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -37,7 +37,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_NotAnId) {
|
|||
|
||||
TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_NoDecorations) {
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(1);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -50,7 +50,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_OneDecoration) {
|
|||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %float
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(10);
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::Block)}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -64,7 +64,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_Duplicate) {
|
|||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %float
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(10);
|
||||
EXPECT_THAT(decorations, UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::Block)}));
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -78,7 +78,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_MultiDecoration) {
|
|||
%float = OpTypeFloat 32
|
||||
%5 = OpConstant %float 3.14
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(5);
|
||||
EXPECT_THAT(decorations,
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::RelaxedPrecision)},
|
||||
|
@ -89,7 +89,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_MultiDecoration) {
|
|||
|
||||
TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_NotAnId) {
|
||||
auto p = parser(test::Assemble(""));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsForMember(42, 9);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -98,7 +98,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_NotAnId) {
|
|||
|
||||
TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_NotAStruct) {
|
||||
auto p = parser(test::Assemble("%1 = OpTypeVoid"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(1);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -110,7 +110,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_MemberWithoutDecorat
|
|||
%uint = OpTypeInt 32 0
|
||||
%10 = OpTypeStruct %uint
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsForMember(10, 0);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -123,7 +123,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_RelaxedPrecision) {
|
|||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %float
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
auto decorations = p->GetDecorationsForMember(10, 0);
|
||||
EXPECT_THAT(decorations,
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::RelaxedPrecision)}));
|
||||
|
@ -138,7 +138,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_Duplicate) {
|
|||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %float
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
auto decorations = p->GetDecorationsForMember(10, 0);
|
||||
EXPECT_THAT(decorations,
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::RelaxedPrecision)}));
|
||||
|
@ -155,7 +155,7 @@ TEST_F(SpvParserGetDecorationsTest, DISABLED_GetDecorationsForMember_OneDecorati
|
|||
%arr = OpTypeArray %uint %uint_2
|
||||
%10 = OpTypeStruct %uint %arr
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
auto decorations = p->GetDecorationsForMember(10, 1);
|
||||
EXPECT_THAT(decorations,
|
||||
UnorderedElementsAre(Decoration{uint32_t(spv::Decoration::ArrayStride), 12}));
|
||||
|
@ -179,7 +179,7 @@ TEST_F(SpvParserGetDecorationsTest, DISABLED_GetDecorationsForMember_MultiDecora
|
|||
%arr = OpTypeArray %mat %uint_2
|
||||
%50 = OpTypeStruct %uint %float %arr
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
|
||||
EXPECT_TRUE(p->GetDecorationsForMember(50, 0).empty());
|
||||
EXPECT_THAT(p->GetDecorationsForMember(50, 1),
|
||||
|
@ -199,7 +199,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_Restrict) {
|
|||
%ptr = OpTypePointer Workgroup %float
|
||||
%10 = OpVariable %ptr Workgroup
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsFor(10);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -215,7 +215,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_Restrict) {
|
|||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %float
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule());
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule());
|
||||
auto decorations = p->GetDecorationsForMember(10, 0);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -230,7 +230,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsFor_RestrictPointer) {
|
|||
%ptr = OpTypePointer Workgroup %float
|
||||
%10 = OpVariable %ptr Workgroup
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
auto decorations = p->GetDecorationsFor(10);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
@ -246,7 +246,7 @@ TEST_F(SpvParserGetDecorationsTest, GetDecorationsForMember_RestrictPointer) {
|
|||
%float = OpTypeFloat 32
|
||||
%10 = OpTypeStruct %float
|
||||
)"));
|
||||
EXPECT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error();
|
||||
auto decorations = p->GetDecorationsFor(10);
|
||||
EXPECT_TRUE(decorations.empty());
|
||||
EXPECT_TRUE(p->error().empty());
|
||||
|
|
Loading…
Reference in New Issue