Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator test: artificially lower limit on local var limit #1633

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions test/val/val_limits_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,11 @@ TEST_F(ValidateLimits, CustomizedNumGlobalVarsBad) {
}

// Valid: module has 524,287 local variables.
TEST_F(ValidateLimits, NumLocalVarsGood) {
int num_locals = 524287;
// Note: AppVeyor limits process time to 300s. For a VisualStudio Debug
// build, going up to 524287 local variables gets too close to that
// limit. So test with an artificially lowered limit.
TEST_F(ValidateLimits, NumLocalVarsGoodArtificiallyLowLimit5K) {
int num_locals = 5000;
std::ostringstream spirv;
spirv << header << R"(
%int = OpTypeInt 32 0
Expand All @@ -428,12 +431,16 @@ TEST_F(ValidateLimits, NumLocalVarsGood) {
)";

CompileSuccessfully(spirv.str());
// Artificially limit it.
spvValidatorOptionsSetUniversalLimit(
options_, spv_validator_limit_max_local_variables, num_locals);
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
}

// Invalid: module has 524,288 local variables (limit is 524,287).
TEST_F(ValidateLimits, NumLocalVarsBad) {
int num_locals = 524288;
// Artificially limit the check to 5001.
TEST_F(ValidateLimits, NumLocalVarsBadArtificiallyLowLimit5K) {
int num_locals = 5001;
std::ostringstream spirv;
spirv << header << R"(
%int = OpTypeInt 32 0
Expand All @@ -454,10 +461,12 @@ TEST_F(ValidateLimits, NumLocalVarsBad) {
)";

CompileSuccessfully(spirv.str());
spvValidatorOptionsSetUniversalLimit(
options_, spv_validator_limit_max_local_variables, 5000u);
EXPECT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
HasSubstr("Number of local variables ('Function' Storage Class) "
"exceeded the valid limit (524287)."));
"exceeded the valid limit (5000)."));
}

// Valid: module has 100 local variables (limit is 100).
Expand Down