Skip to content

Commit

Permalink
[SPIRV] simplify FileTest. (microsoft#5673)
Browse files Browse the repository at this point in the history
Remove unused method for runFileTest and enable validation for all
tests. This will help code review when convert to lit FileCheck test.
  • Loading branch information
python3kgae authored Sep 11, 2023
1 parent 67fd9dd commit 4f0ace9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
24 changes: 9 additions & 15 deletions tools/clang/unittests/SPIRV/CodeGenSpirvTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ TEST_F(FileTest, InheritanceLayoutEmptyStruct) {
runFileTest("oo.inheritance.layout.empty-struct.hlsl");
}
TEST_F(FileTest, InheritanceCallMethodOfBase) {
runFileTest("oo.inheritance.call.base.method.hlsl", Expect::Success,
/* runValidation */ false);
setBeforeHLSLLegalization();
runFileTest("oo.inheritance.call.base.method.hlsl", Expect::Success);
}
TEST_F(FileTest, InheritanceBaseWithByteAddressBuffer) {
runFileTest("oo.inheritance.base-with-byte-address-buffer.hlsl");
Expand Down Expand Up @@ -1752,13 +1752,12 @@ TEST_F(FileTest, AutoShiftBindings) {

TEST_F(FileTest, BindingStructureOfResourcesOptimized) {
// After optimization is performed, this binary should pass validation.
runFileTest("vk.binding.global-struct-of-resources.optimized.hlsl",
Expect::Success, /*runValidation*/ true);
runFileTest("vk.binding.global-struct-of-resources.optimized.hlsl");
}

TEST_F(FileTest, BindingStructureOfResourcesAndNonResourcesError1) {
runFileTest("vk.binding.global-struct-of-resource-mix.error.1.hlsl",
Expect::Failure, /*runValidation*/ false);
Expect::Failure);
}

TEST_F(FileTest, BindingStructureOfResourcesAndNonResourcesError2) {
Expand All @@ -1773,8 +1772,7 @@ TEST_F(FileTest, BindingStructureOfResourcesContainsBufferError) {
}
TEST_F(FileTest, BindingStructureOfResourcesPassLegalization) {
runFileTest("vk.binding.global-struct-of-resources.pass-legalization.hlsl",
Expect::Success,
/*runValidation*/ true);
Expect::Success);
}

TEST_F(FileTest, VulkanPushConstant) { runFileTest("vk.push-constant.hlsl"); }
Expand Down Expand Up @@ -2161,14 +2159,10 @@ TEST_F(FileTest, MeshShadingNVMeshError14) {
runFileTest("meshshading.nv.error14.mesh.hlsl", Expect::Failure);
}
TEST_F(FileTest, MeshShadingNVAmplification) {
// TODO: Re-enable spirv-val once issue#3006 is fixed.
runFileTest("meshshading.nv.amplification.hlsl", Expect::Success,
/* runValidation */ false);
runFileTest("meshshading.nv.amplification.hlsl", Expect::Success);
}
TEST_F(FileTest, MeshShadingNVAmplificationFunCall) {
// TODO: Re-enable spirv-val once issue#3006 is fixed.
runFileTest("meshshading.nv.fncall.amplification.hlsl", Expect::Success,
/* runValidation */ false);
runFileTest("meshshading.nv.fncall.amplification.hlsl", Expect::Success);
}
TEST_F(FileTest, MeshShadingNVAmplificationError1) {
runFileTest("meshshading.nv.error1.amplification.hlsl", Expect::Failure);
Expand All @@ -2184,9 +2178,9 @@ TEST_F(FileTest, MeshShadingNVAmplificationError4) {
}

TEST_F(FileTest, UseRValueForMemberExprOfArraySubscriptExpr) {
setBeforeHLSLLegalization();
runFileTest("use.rvalue.for.member-expr.of.array-subscript.hlsl",
Expect::Success,
/* runValidation */ false);
Expect::Success);
}

TEST_F(FileTest, ReduceLoadSize) { runFileTest("reduce.load.size.hlsl"); }
Expand Down
4 changes: 2 additions & 2 deletions tools/clang/unittests/SPIRV/FileTestFixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ bool FileTest::parseCommand() {
return true;
}

void FileTest::runFileTest(llvm::StringRef filename, Expect expect,
bool runValidation) {
void FileTest::runFileTest(llvm::StringRef filename, Expect expect) {
bool runValidation = true;
if (beforeHLSLLegalization)
assert(runValidation);

Expand Down
6 changes: 1 addition & 5 deletions tools/clang/unittests/SPIRV/FileTestFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ class FileTest : public ::testing::Test {
glLayout(false), dxLayout(false) {}

void setBeforeHLSLLegalization() { beforeHLSLLegalization = true; }
void setGlLayout() { glLayout = true; }
void setDxLayout() { dxLayout = true; }
void setScalarLayout() { scalarLayout = true; }

/// \brief Runs a test with the given input HLSL file.
///
/// The first line of HLSL code must start with "// RUN:" and following DXC
/// arguments to run the test. Next lines must be proper HLSL code for the
/// test. It uses file check style output check e.g., "// CHECK: ...".
void runFileTest(llvm::StringRef path, Expect expect = Expect::Success,
bool runValidation = true);
void runFileTest(llvm::StringRef path, Expect expect = Expect::Success);

/// \brief Runs a test with the given HLSL code.
///
Expand Down

0 comments on commit 4f0ace9

Please sign in to comment.