From 255cfe829f1da7186e89b67827ef025da7304214 Mon Sep 17 00:00:00 2001 From: Sarah Mashayekhi Date: Thu, 20 Aug 2020 20:52:29 +0000 Subject: [PATCH] [validation] Add disabled test for v-0019-entry point functions must exist Bug: tint: 6 Change-Id: I303fab6e0cd4a807173bef8f69e14220480fbb9a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27080 Commit-Queue: David Neto Reviewed-by: David Neto --- src/validator_function_test.cc | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/validator_function_test.cc b/src/validator_function_test.cc index fb484c7250..00606f6aab 100644 --- a/src/validator_function_test.cc +++ b/src/validator_function_test.cc @@ -17,6 +17,7 @@ #include "gtest/gtest.h" #include "spirv/unified1/GLSL.std.450.h" #include "src/ast/call_statement.h" +#include "src/ast/entry_point.h" #include "src/ast/return_statement.h" #include "src/ast/scalar_constructor_expression.h" #include "src/ast/sint_literal.h" @@ -240,5 +241,49 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { EXPECT_EQ(v.error(), "12:34: v-0004: recursion is not allowed: 'func'"); } +TEST_F(ValidateFunctionTest, DISABLED_EntryPointFunctionMissing_Fail) { + // entry_point vertex as "main" = vtx_main + // fn frag_main() -> void { return; } + ast::type::VoidType void_type; + ast::VariableList params; + auto func = std::make_unique("vtx_main", std::move(params), + &void_type); + auto body = std::make_unique(); + body->append(std::make_unique()); + func->set_body(std::move(body)); + + auto entry_point = std::make_unique( + Source{12, 34}, ast::PipelineStage::kVertex, "main", "frag_main"); + + mod()->AddFunction(std::move(func)); + mod()->AddEntryPoint(std::move(entry_point)); + EXPECT_TRUE(td()->Determine()) << td()->error(); + tint::ValidatorImpl v; + EXPECT_FALSE(v.Validate(mod())); + EXPECT_EQ(v.error(), + "12:34: v-0019: Function used in entry point does not exist: " + "'frag_main'"); +} + +TEST_F(ValidateFunctionTest, EntryPointFunctionExist_Pass) { + // entry_point vertex as "main" = vtx_main + // fn vtx_main() -> void { return; } + ast::type::VoidType void_type; + ast::VariableList params; + auto func = std::make_unique("vtx_main", std::move(params), + &void_type); + auto body = std::make_unique(); + body->append(std::make_unique()); + func->set_body(std::move(body)); + + auto entry_point = std::make_unique( + ast::PipelineStage::kVertex, "main", "vtx_main"); + + mod()->AddFunction(std::move(func)); + mod()->AddEntryPoint(std::move(entry_point)); + EXPECT_TRUE(td()->Determine()) << td()->error(); + tint::ValidatorImpl v; + EXPECT_TRUE(v.Validate(mod())) << v.error(); +} } // namespace } // namespace tint