[valdiation] Add disable test for v-0020, the <entry point name, pipeline stage> must be unique

Bug: tint: 6
Change-Id: I3fa9c1427ee99c9a442369516ddef0c11f33304f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27280
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Sarah Mashayekhi 2020-08-25 16:06:24 +00:00 committed by Commit Bot service account
parent 4fb431c90e
commit 6a0e28b624
1 changed files with 89 additions and 1 deletions

View File

@ -312,6 +312,94 @@ TEST_F(ValidateFunctionTest, EntryPointFunctionWithParams_Fail) {
"12:34: v-0023: Entry point function must accept no parameters: "
"'vtx_func'");
}
//
TEST_F(ValidateFunctionTest,
DISABLED_EntryPointFunctionPairMustBeUniqueDuplicate_Fail) {
// entry_point vertex = vtx_main
// entry_point vertex = vtx_main
// fn vtx_main() -> void { return; }
ast::type::VoidType void_type;
ast::VariableList params;
auto func = std::make_unique<ast::Function>("vtx_main", std::move(params),
&void_type);
auto body = std::make_unique<ast::BlockStatement>();
body->append(std::make_unique<ast::ReturnStatement>());
func->set_body(std::move(body));
auto entry_point = std::make_unique<ast::EntryPoint>(
ast::PipelineStage::kVertex, "", "vtx_main");
auto entry_point_copy = std::make_unique<ast::EntryPoint>(
Source{12, 34}, ast::PipelineStage::kVertex, "", "vtx_main");
mod()->AddFunction(std::move(func));
mod()->AddEntryPoint(std::move(entry_point));
mod()->AddEntryPoint(std::move(entry_point_copy));
EXPECT_TRUE(td()->Determine()) << td()->error();
EXPECT_FALSE(v()->Validate(mod()));
EXPECT_EQ(v()->error(),
"12:34: v-0020: Entry point and function pair must be unique");
}
TEST_F(ValidateFunctionTest,
DISABLED_EntryPointFunctionPairMustBeUniqueTowVertex_Fail) {
// entry_point vertex as "main" = vtx_func1
// entry_point vertex as "main" = vtx_func0
// fn vtx_func1() -> void { return; }
// fn vtx_func0() -> void { return; }
ast::type::VoidType void_type;
ast::VariableList params;
auto func = std::make_unique<ast::Function>("vtx_func0", std::move(params),
&void_type);
auto body = std::make_unique<ast::BlockStatement>();
body->append(std::make_unique<ast::ReturnStatement>());
func->set_body(std::move(body));
ast::VariableList params1;
auto func1 = std::make_unique<ast::Function>("vtx_func1", std::move(params1),
&void_type);
auto body1 = std::make_unique<ast::BlockStatement>();
body1->append(std::make_unique<ast::ReturnStatement>());
func1->set_body(std::move(body1));
auto entry_point = std::make_unique<ast::EntryPoint>(
ast::PipelineStage::kVertex, "main", "vtx_func0");
auto entry_point1 = std::make_unique<ast::EntryPoint>(
Source{12, 34}, ast::PipelineStage::kVertex, "main", "vtx_func1");
mod()->AddFunction(std::move(func));
mod()->AddFunction(std::move(func1));
mod()->AddEntryPoint(std::move(entry_point));
mod()->AddEntryPoint(std::move(entry_point1));
EXPECT_TRUE(td()->Determine()) << td()->error();
EXPECT_FALSE(v()->Validate(mod()));
EXPECT_EQ(v()->error(),
"12:34: v-0020: Entry point and function pair must be unique");
}
TEST_F(ValidateFunctionTest,
DISABLED_EntryPointFunctionPairMustBeUniqueSameFuncDiffStage_Pass) {
// entry_point vertex as "main" = vtx_func
// entry_point fragment as "main" = vtx_func
// fn vtx_func() -> void { return; }
ast::type::VoidType void_type;
ast::VariableList params;
auto func = std::make_unique<ast::Function>("vtx_func", std::move(params),
&void_type);
auto body = std::make_unique<ast::BlockStatement>();
body->append(std::make_unique<ast::ReturnStatement>());
func->set_body(std::move(body));
auto entry_point = std::make_unique<ast::EntryPoint>(
ast::PipelineStage::kVertex, "main", "vtx_func");
auto entry_point1 = std::make_unique<ast::EntryPoint>(
Source{12, 34}, ast::PipelineStage::kFragment, "main", "vtx_func");
mod()->AddFunction(std::move(func));
mod()->AddEntryPoint(std::move(entry_point));
mod()->AddEntryPoint(std::move(entry_point1));
EXPECT_TRUE(td()->Determine()) << td()->error();
EXPECT_TRUE(v()->Validate(mod())) << v()->error();
}
} // namespace
} // namespace tint