Skip to content

Commit 7a82fa9

Browse files
author
joaosaffran
committed
fixing tests
2 parents 852ac25 + 74f7226 commit 7a82fa9

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ struct RootSignatureValidations {
555555
}
556556

557557
static bool validateVersion(uint32_t Version) {
558-
return (Version < 1 || Version > 2);
558+
return !(Version == 1 || Version == 2);
559559
}
560560
};
561561

llvm/lib/Object/DXContainer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,16 @@ Error DirectX::RootSignature::parse(StringRef Data) {
246246
const char *Current = Data.begin();
247247

248248
// Root Signature headers expects 6 integers to be present.
249-
if (Data.size() < 6 * sizeof(uint32_t)) {
250-
return parseFailed("Invalid data. Too small.");
251-
}
249+
if (Data.size() < 6 * sizeof(uint32_t))
250+
return parseFailed(
251+
"Invalid root signature, insufficient space for header.");
252252

253253
uint32_t VValue =
254254
support::endian::read<uint32_t, llvm::endianness::little>(Current);
255255
Current += sizeof(uint32_t);
256256

257257
if (dxbc::RootSignatureValidations::validateVersion(VValue))
258-
return make_error<GenericBinaryError>("Invalid Version");
258+
return make_error<GenericBinaryError>("Invalid Root Signature Version");
259259
Version = VValue;
260260

261261
NumParameters =
@@ -279,7 +279,7 @@ Error DirectX::RootSignature::parse(StringRef Data) {
279279
Current += sizeof(uint32_t);
280280

281281
if (dxbc::RootSignatureValidations::validateRootFlag(FValue))
282-
return make_error<GenericBinaryError>("Invalid flag");
282+
return make_error<GenericBinaryError>("Invalid Root Signature flag");
283283
Flags = FValue;
284284

285285
return Error::success();

llvm/lib/Target/DirectX/DXILRootSignature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ bool ModuleRootSignature::parse(NamedMDNode *Root, const Function *EF) {
134134

135135
bool ModuleRootSignature::validate() {
136136
if (dxbc::RootSignatureValidations::validateRootFlag(Flags)) {
137-
return reportError("Invalid flag value for RootFlag");
137+
return reportError("Invalid Root Signature flag value");
138138
}
139139
return false;
140140
}

llvm/unittests/Object/DXContainerTest.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,10 @@ TEST(RootSignature, ParseRootFlags) {
855855
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
856856
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
857857
};
858-
EXPECT_THAT_EXPECTED(DXContainer::create(getMemoryBuffer<64>(Buffer)),
859-
FailedWithMessage("Invalid data. Too small."));
858+
EXPECT_THAT_EXPECTED(
859+
DXContainer::create(getMemoryBuffer<64>(Buffer)),
860+
FailedWithMessage(
861+
"Invalid root signature, insufficient space for header."));
860862
}
861863
{
862864
// Version has been changed to an invalid number.
@@ -868,8 +870,9 @@ TEST(RootSignature, ParseRootFlags) {
868870
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
869871
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
870872
};
871-
EXPECT_THAT_EXPECTED(DXContainer::create(getMemoryBuffer<68>(Buffer)),
872-
FailedWithMessage("Invalid Version"));
873+
EXPECT_THAT_EXPECTED(
874+
DXContainer::create(getMemoryBuffer<68>(Buffer)),
875+
FailedWithMessage("Invalid Root Signature Version"));
873876
}
874877
{
875878
// Flag has been set to an invalid value
@@ -881,7 +884,8 @@ TEST(RootSignature, ParseRootFlags) {
881884
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
882885
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xFF,
883886
};
884-
EXPECT_THAT_EXPECTED(DXContainer::create(getMemoryBuffer<68>(Buffer)),
885-
FailedWithMessage("Invalid flag"));
887+
EXPECT_THAT_EXPECTED(
888+
DXContainer::create(getMemoryBuffer<68>(Buffer)),
889+
FailedWithMessage("Invalid Root Signature flag"));
886890
}
887891
}

0 commit comments

Comments
 (0)