From 76fca14750e3ca536e9b65a99ed55730cd704403 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Fri, 9 Dec 2022 11:57:07 -0600 Subject: [PATCH] [NFC] Update DXContainer tests to use fake parts The tests that are focused on testing the file structure should use fake part names so that the errors get triggered consistently. As we add parsing support for known data types and structures under the parts the parsing errors change to be more semantically accurate. This change ensures the general errors continue to work with less churn on the test cases in the future. --- llvm/test/tools/obj2yaml/DXContainer/DXILPart.yaml | 12 +++---- .../DXContainer/ExplicitSizeAndOffsets.yaml | 28 ++++++++-------- .../tools/obj2yaml/DXContainer/InvalidOffset.yaml | 2 +- .../tools/obj2yaml/DXContainer/InvalidSize.yaml | 4 +-- .../obj2yaml/DXContainer/OmitSizeAndOffsets.yaml | 28 ++++++++-------- .../tools/obj2yaml/DXContainer/ShaderFlags.yaml | 14 ++------ .../obj2yaml/DXContainer/ShaderFlagsEmpty.yaml | 16 ++------- llvm/unittests/Object/DXContainerTest.cpp | 28 ++++++++-------- llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp | 38 +++++++++++----------- 9 files changed, 76 insertions(+), 94 deletions(-) diff --git a/llvm/test/tools/obj2yaml/DXContainer/DXILPart.yaml b/llvm/test/tools/obj2yaml/DXContainer/DXILPart.yaml index 4ee8c42..58508f2 100644 --- a/llvm/test/tools/obj2yaml/DXContainer/DXILPart.yaml +++ b/llvm/test/tools/obj2yaml/DXContainer/DXILPart.yaml @@ -15,17 +15,17 @@ Header: PartCount: 7 PartOffsets: [ 60, 76, 92, 108, 236, 1932, 1960 ] Parts: - - Name: SFI0 + - Name: FKE0 Size: 8 - - Name: ISG1 + - Name: FKE1 Size: 8 - - Name: OSG1 + - Name: FKE2 Size: 8 - - Name: PSV0 + - Name: FKE3 Size: 120 - - Name: STAT + - Name: FKE4 Size: 1688 - - Name: HASH + - Name: FKE5 Size: 20 - Name: DXIL Size: 28 diff --git a/llvm/test/tools/obj2yaml/DXContainer/ExplicitSizeAndOffsets.yaml b/llvm/test/tools/obj2yaml/DXContainer/ExplicitSizeAndOffsets.yaml index 040aeb0..5d28866 100644 --- a/llvm/test/tools/obj2yaml/DXContainer/ExplicitSizeAndOffsets.yaml +++ b/llvm/test/tools/obj2yaml/DXContainer/ExplicitSizeAndOffsets.yaml @@ -11,19 +11,19 @@ Header: PartCount: 7 PartOffsets: [ 60, 76, 92, 108, 124, 140, 168 ] Parts: - - Name: SFI0 + - Name: FKE0 Size: 8 - - Name: ISG1 + - Name: FKE1 Size: 8 - - Name: OSG1 + - Name: FKE2 Size: 8 - - Name: PSV0 + - Name: FKE3 Size: 8 - - Name: STAT + - Name: FKE4 Size: 8 - - Name: HASH + - Name: FKE5 Size: 20 - - Name: CXIL + - Name: FKE6 Size: 8 ... @@ -38,18 +38,18 @@ Parts: # CHECK-NEXT: PartCount: 7 # CHECK-NEXT: PartOffsets: [ 60, 76, 92, 108, 124, 140, 168 ] # CHECK-NEXT: Parts: -# CHECK-NEXT: - Name: SFI0 +# CHECK-NEXT: - Name: FKE0 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: ISG1 +# CHECK-NEXT: - Name: FKE1 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: OSG1 +# CHECK-NEXT: - Name: FKE2 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: PSV0 +# CHECK-NEXT: - Name: FKE3 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: STAT +# CHECK-NEXT: - Name: FKE4 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: HASH +# CHECK-NEXT: - Name: FKE5 # CHECK-NEXT: Size: 20 -# CHECK-NEXT: - Name: CXIL +# CHECK-NEXT: - Name: FKE6 # CHECK-NEXT: Size: 8 # CHECK-NEXT: ... diff --git a/llvm/test/tools/obj2yaml/DXContainer/InvalidOffset.yaml b/llvm/test/tools/obj2yaml/DXContainer/InvalidOffset.yaml index b7e25e4..0ba4980 100644 --- a/llvm/test/tools/obj2yaml/DXContainer/InvalidOffset.yaml +++ b/llvm/test/tools/obj2yaml/DXContainer/InvalidOffset.yaml @@ -12,6 +12,6 @@ Header: PartCount: 1 PartOffsets: [ 0 ] Parts: - - Name: SFI0 + - Name: FKE0 Size: 8 ... diff --git a/llvm/test/tools/obj2yaml/DXContainer/InvalidSize.yaml b/llvm/test/tools/obj2yaml/DXContainer/InvalidSize.yaml index e79aa4c..0dd067c 100644 --- a/llvm/test/tools/obj2yaml/DXContainer/InvalidSize.yaml +++ b/llvm/test/tools/obj2yaml/DXContainer/InvalidSize.yaml @@ -11,8 +11,8 @@ Header: FileSize: 64 PartCount: 2 Parts: - - Name: SFI0 + - Name: FKE0 Size: 8 - - Name: ISG1 + - Name: FKE1 Size: 8 ... diff --git a/llvm/test/tools/obj2yaml/DXContainer/OmitSizeAndOffsets.yaml b/llvm/test/tools/obj2yaml/DXContainer/OmitSizeAndOffsets.yaml index 62efd41..fae268f 100644 --- a/llvm/test/tools/obj2yaml/DXContainer/OmitSizeAndOffsets.yaml +++ b/llvm/test/tools/obj2yaml/DXContainer/OmitSizeAndOffsets.yaml @@ -9,19 +9,19 @@ Header: Minor: 0 PartCount: 7 Parts: - - Name: SFI0 + - Name: FKE0 Size: 8 - - Name: ISG1 + - Name: FKE1 Size: 8 - - Name: OSG1 + - Name: FKE2 Size: 8 - - Name: PSV0 + - Name: FKE3 Size: 8 - - Name: STAT + - Name: FKE4 Size: 8 - - Name: HASH + - Name: FKE5 Size: 20 - - Name: CXIL + - Name: FKE6 Size: 8 ... @@ -36,18 +36,18 @@ Parts: # CHECK-NEXT: PartCount: 7 # CHECK-NEXT: PartOffsets: [ 60, 76, 92, 108, 124, 140, 168 ] # CHECK-NEXT: Parts: -# CHECK-NEXT: - Name: SFI0 +# CHECK-NEXT: - Name: FKE0 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: ISG1 +# CHECK-NEXT: - Name: FKE1 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: OSG1 +# CHECK-NEXT: - Name: FKE2 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: PSV0 +# CHECK-NEXT: - Name: FKE3 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: STAT +# CHECK-NEXT: - Name: FKE4 # CHECK-NEXT: Size: 8 -# CHECK-NEXT: - Name: HASH +# CHECK-NEXT: - Name: FKE5 # CHECK-NEXT: Size: 20 -# CHECK-NEXT: - Name: CXIL +# CHECK-NEXT: - Name: FKE6 # CHECK-NEXT: Size: 8 # CHECK-NEXT: ... diff --git a/llvm/test/tools/obj2yaml/DXContainer/ShaderFlags.yaml b/llvm/test/tools/obj2yaml/DXContainer/ShaderFlags.yaml index 2a5a3ff..165b397 100644 --- a/llvm/test/tools/obj2yaml/DXContainer/ShaderFlags.yaml +++ b/llvm/test/tools/obj2yaml/DXContainer/ShaderFlags.yaml @@ -8,7 +8,7 @@ Header: Version: Major: 1 Minor: 0 - PartCount: 7 + PartCount: 2 Parts: - Name: SFI0 Size: 8 @@ -45,17 +45,7 @@ Parts: AdvancedTextureOps: true WriteableMSAATextures: false NextUnusedBit: true - - Name: ISG1 - Size: 8 - - Name: OSG1 - Size: 8 - - Name: PSV0 - Size: 8 - - Name: STAT - Size: 8 - - Name: HASH - Size: 20 - - Name: CXIL + - Name: FKE0 Size: 8 ... diff --git a/llvm/test/tools/obj2yaml/DXContainer/ShaderFlagsEmpty.yaml b/llvm/test/tools/obj2yaml/DXContainer/ShaderFlagsEmpty.yaml index ef73eb8..086c7e9 100644 --- a/llvm/test/tools/obj2yaml/DXContainer/ShaderFlagsEmpty.yaml +++ b/llvm/test/tools/obj2yaml/DXContainer/ShaderFlagsEmpty.yaml @@ -7,7 +7,7 @@ Header: Version: Major: 1 Minor: 0 - PartCount: 7 + PartCount: 2 Parts: - Name: SFI0 Size: 8 @@ -44,17 +44,7 @@ Parts: AdvancedTextureOps: false WriteableMSAATextures: false NextUnusedBit: false - - Name: ISG1 - Size: 8 - - Name: OSG1 - Size: 8 - - Name: PSV0 - Size: 8 - - Name: STAT - Size: 8 - - Name: HASH - Size: 20 - - Name: CXIL + - Name: FKE0 Size: 8 ... @@ -62,4 +52,4 @@ Parts: # CHECK-NEXT: - Name: SFI0 # CHECK-NEXT: Size: 8 # CHECK-NOT: Flags: -# CHECK-NEXT: - Name: ISG1 +# CHECK-NEXT: - Name: FKE0 diff --git a/llvm/unittests/Object/DXContainerTest.cpp b/llvm/unittests/Object/DXContainerTest.cpp index 14fb4b8..4145ed6 100644 --- a/llvm/unittests/Object/DXContainerTest.cpp +++ b/llvm/unittests/Object/DXContainerTest.cpp @@ -88,11 +88,11 @@ TEST(DXCFile, ParseEmptyParts) { 0x70, 0x0D, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, - 0x53, 0x46, 0x49, 0x30, 0x00, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x31, - 0x00, 0x00, 0x00, 0x00, 0x4F, 0x53, 0x47, 0x31, 0x00, 0x00, 0x00, 0x00, - 0x50, 0x53, 0x56, 0x30, 0x00, 0x00, 0x00, 0x00, 0x53, 0x54, 0x41, 0x54, - 0x00, 0x00, 0x00, 0x00, 0x43, 0x58, 0x49, 0x4C, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x45, 0x41, 0x44, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x4B, 0x45, 0x30, 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x31, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x4B, 0x45, 0x33, 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x34, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x35, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x4B, 0x45, 0x36, 0x00, 0x00, 0x00, 0x00, }; DXContainer C = llvm::cantFail(DXContainer::create(getMemoryBuffer<116>(Buffer))); @@ -108,21 +108,23 @@ TEST(DXCFile, ParseEmptyParts) { EXPECT_EQ(ElementsVisited, 7); { + // These are all intended to be fake part names so that the parser doesn't + // try to parse the part data. auto It = C.begin(); - EXPECT_TRUE(memcmp(It->Part.Name, "SFI0", 4) == 0); + EXPECT_TRUE(memcmp(It->Part.Name, "FKE0", 4) == 0); ++It; - EXPECT_TRUE(memcmp(It->Part.Name, "ISG1", 4) == 0); + EXPECT_TRUE(memcmp(It->Part.Name, "FKE1", 4) == 0); ++It; - EXPECT_TRUE(memcmp(It->Part.Name, "OSG1", 4) == 0); + EXPECT_TRUE(memcmp(It->Part.Name, "FKE2", 4) == 0); ++It; - EXPECT_TRUE(memcmp(It->Part.Name, "PSV0", 4) == 0); + EXPECT_TRUE(memcmp(It->Part.Name, "FKE3", 4) == 0); ++It; - EXPECT_TRUE(memcmp(It->Part.Name, "STAT", 4) == 0); + EXPECT_TRUE(memcmp(It->Part.Name, "FKE4", 4) == 0); ++It; - EXPECT_TRUE(memcmp(It->Part.Name, "CXIL", 4) == 0); + EXPECT_TRUE(memcmp(It->Part.Name, "FKE5", 4) == 0); ++It; - EXPECT_TRUE(memcmp(It->Part.Name, "DEAD", 4) == 0); + EXPECT_TRUE(memcmp(It->Part.Name, "FKE6", 4) == 0); ++It; // Don't increment past the end - EXPECT_TRUE(memcmp(It->Part.Name, "DEAD", 4) == 0); + EXPECT_TRUE(memcmp(It->Part.Name, "FKE6", 4) == 0); } } diff --git a/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp b/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp index 4055222..d423229 100644 --- a/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp +++ b/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp @@ -40,19 +40,19 @@ Header: PartCount: 7 PartOffsets: [ 60, 68, 76, 84, 92, 100, 108 ] Parts: - - Name: SFI0 + - Name: FKE0 Size: 0 - - Name: ISG1 + - Name: FKE1 Size: 0 - - Name: OSG1 + - Name: FKE2 Size: 0 - - Name: PSV0 + - Name: FKE3 Size: 0 - - Name: STAT + - Name: FKE4 Size: 0 - - Name: DXIL + - Name: FKE5 Size: 0 - - Name: DEAD + - Name: FKE6 Size: 0 ... )")); @@ -64,11 +64,11 @@ Parts: 0x74, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, - 0x53, 0x46, 0x49, 0x30, 0x00, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x31, - 0x00, 0x00, 0x00, 0x00, 0x4F, 0x53, 0x47, 0x31, 0x00, 0x00, 0x00, 0x00, - 0x50, 0x53, 0x56, 0x30, 0x00, 0x00, 0x00, 0x00, 0x53, 0x54, 0x41, 0x54, - 0x00, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4C, 0x00, 0x00, 0x00, 0x00, - 0x44, 0x45, 0x41, 0x44, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x4B, 0x45, 0x30, 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x31, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x4B, 0x45, 0x33, 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x34, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x4B, 0x45, 0x35, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x4B, 0x45, 0x36, 0x00, 0x00, 0x00, 0x00, }; EXPECT_EQ(Storage.size(), 116u); @@ -87,19 +87,19 @@ Header: Minor: 0 PartCount: 7 Parts: - - Name: SFI0 + - Name: FKE0 Size: 0 - - Name: ISG1 + - Name: FKE1 Size: 0 - - Name: OSG1 + - Name: FKE2 Size: 0 - - Name: PSV0 + - Name: FKE3 Size: 0 - - Name: STAT + - Name: FKE4 Size: 0 - - Name: DXIL + - Name: FKE5 Size: 0 - - Name: DEAD + - Name: FKE6 Size: 0 ... )")); -- 2.7.4