From 65a45fdf419d77a470c18a344126d2299632db82 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 23 Feb 2023 21:51:15 +0000 Subject: [PATCH] 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 Reviewed-by: Ben Clayton Commit-Queue: Dan Sinclair --- .../spirv/parser_impl_get_decorations_test.cc | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/tint/reader/spirv/parser_impl_get_decorations_test.cc b/src/tint/reader/spirv/parser_impl_get_decorations_test.cc index cbc384fda0..43e6e2dc83 100644 --- a/src/tint/reader/spirv/parser_impl_get_decorations_test.cc +++ b/src/tint/reader/spirv/parser_impl_get_decorations_test.cc @@ -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());