Path: blob/main_old/src/tests/test_expectations/GPUTestExpectationsParser_unittest.cpp
1693 views
//1// Copyright 2019 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// GPUTestExpectationsParser_unittest.cpp: Unit tests for GPUTestExpectationsParser*6//78#include "tests/test_expectations/GPUTestExpectationsParser.h"9#include <gtest/gtest.h>10#include "tests/test_expectations/GPUTestConfig.h"1112using namespace angle;1314namespace15{16enum class ConditionTestType17{18OnLoad,19OnGet,20};2122class GPUTestConfigTester : public GPUTestConfig23{24public:25GPUTestConfigTester()26{27mConditions.reset();28mConditions[GPUTestConfig::kConditionWin] = true;29mConditions[GPUTestConfig::kConditionNVIDIA] = true;30mConditions[GPUTestConfig::kConditionD3D11] = true;31}32};3334class GPUTestExpectationsParserTest : public testing::TestWithParam<ConditionTestType>35{36public:37bool load(const std::string &line)38{39if (GetParam() == ConditionTestType::OnLoad)40{41return parser.loadTestExpectations(config, line);42}43else44{45return parser.loadAllTestExpectations(line);46}47}4849int32_t get(const std::string &testName)50{51if (GetParam() == ConditionTestType::OnLoad)52{53return parser.getTestExpectation(testName);54}55else56{57return parser.getTestExpectationWithConfig(config, testName);58}59}6061GPUTestConfigTester config;62GPUTestExpectationsParser parser;63};6465// A correct entry with a test that's skipped on all platforms should not lead66// to any errors, and should properly return the expectation SKIP.67TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSkip)68{69std::string line =70R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";71EXPECT_TRUE(load(line));72EXPECT_TRUE(parser.getErrorMessages().empty());73EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),74GPUTestExpectationsParser::kGpuTestSkip);75}7677// A correct entry with a test that's failed on all platforms should not lead78// to any errors, and should properly return the expectation FAIL.79TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserFail)80{81std::string line =82R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = FAIL)";83EXPECT_TRUE(load(line));84EXPECT_TRUE(parser.getErrorMessages().empty());85EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),86GPUTestExpectationsParser::kGpuTestFail);87}8889// A correct entry with a test that's passed on all platforms should not lead90// to any errors, and should properly return the expectation PASS.91TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserPass)92{93std::string line =94R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = PASS)";95EXPECT_TRUE(load(line));96EXPECT_TRUE(parser.getErrorMessages().empty());97EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),98GPUTestExpectationsParser::kGpuTestPass);99}100101// A correct entry with a test that's timed out on all platforms should not lead102// to any errors, and should properly return the expectation TIMEOUT.103TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserTimeout)104{105std::string line =106R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = TIMEOUT)";107EXPECT_TRUE(load(line));108EXPECT_TRUE(parser.getErrorMessages().empty());109EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),110GPUTestExpectationsParser::kGpuTestTimeout);111}112113// A correct entry with a test that's flaky on all platforms should not lead114// to any errors, and should properly return the expectation FLAKY.115TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserFlaky)116{117std::string line =118R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = FLAKY)";119EXPECT_TRUE(load(line));120EXPECT_TRUE(parser.getErrorMessages().empty());121EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),122GPUTestExpectationsParser::kGpuTestFlaky);123}124125// A correct entry with a test that's skipped on windows should not lead126// to any errors, and should properly return the expectation SKIP on this127// tester.128TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineWin)129{130std::string line =131R"(100 WIN : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";132EXPECT_TRUE(load(line));133EXPECT_TRUE(parser.getErrorMessages().empty());134EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),135GPUTestExpectationsParser::kGpuTestSkip);136}137138// A correct entry with a test that's skipped on windows/NVIDIA should not lead139// to any errors, and should properly return the expectation SKIP on this140// tester.141TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineWinNVIDIA)142{143std::string line =144R"(100 WIN NVIDIA : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";145EXPECT_TRUE(load(line));146EXPECT_TRUE(parser.getErrorMessages().empty());147EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),148GPUTestExpectationsParser::kGpuTestSkip);149}150151// A correct entry with a test that's skipped on windows/NVIDIA/D3D11 should not152// lead to any errors, and should properly return the expectation SKIP on this153// tester.154TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineWinNVIDIAD3D11)155{156std::string line =157R"(100 WIN NVIDIA D3D11 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";158EXPECT_TRUE(load(line));159EXPECT_TRUE(parser.getErrorMessages().empty());160EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),161GPUTestExpectationsParser::kGpuTestSkip);162}163164// Same as GPUTestExpectationsParserSingleLineWinNVIDIAD3D11, but verifying that the order165// of these conditions doesn't matter166TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineWinNVIDIAD3D11OtherOrder)167{168std::string line =169R"(100 D3D11 NVIDIA WIN : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";170EXPECT_TRUE(load(line));171EXPECT_TRUE(parser.getErrorMessages().empty());172EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),173GPUTestExpectationsParser::kGpuTestSkip);174}175176// A correct entry with a test that's skipped on mac should not lead177// to any errors, and should default to PASS on this tester (windows).178TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineMac)179{180std::string line =181R"(100 MAC : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";182EXPECT_TRUE(load(line));183EXPECT_TRUE(parser.getErrorMessages().empty());184EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),185GPUTestExpectationsParser::kGpuTestPass);186}187188// A correct entry with a test that has conflicting entries should not lead189// to any errors, and should default to PASS.190// (https:anglebug.com/3368) In the future, this condition should cause an191// error192TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserSingleLineConflict)193{194std::string line =195R"(100 WIN MAC : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";196EXPECT_TRUE(load(line));197EXPECT_TRUE(parser.getErrorMessages().empty());198EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),199GPUTestExpectationsParser::kGpuTestPass);200}201202// A line without a bug ID should return an error and not add the expectation.203TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingBugId)204{205std::string line = R"( : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";206EXPECT_FALSE(load(line));207EXPECT_EQ(parser.getErrorMessages().size(), 1u);208if (parser.getErrorMessages().size() >= 1)209{210EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");211}212// Default behavior is to let missing tests pass213EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),214GPUTestExpectationsParser::kGpuTestPass);215}216217// A line without a bug ID should return an error and not add the expectation, (even if218// the line contains conditions that might be mistaken for a bug id)219TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingBugIdWithConditions)220{221std::string line =222R"(WIN D3D11 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";223EXPECT_FALSE(load(line));224EXPECT_EQ(parser.getErrorMessages().size(), 1u);225if (parser.getErrorMessages().size() >= 1)226{227EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");228}229// Default behavior is to let missing tests pass230EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),231GPUTestExpectationsParser::kGpuTestPass);232}233234// A line without a colon should return an error and not add the expectation.235TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingColon)236{237std::string line = R"(100 dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";238EXPECT_FALSE(load(line));239EXPECT_EQ(parser.getErrorMessages().size(), 1u);240if (parser.getErrorMessages().size() >= 1)241{242EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");243}244// Default behavior is to let missing tests pass245EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),246GPUTestExpectationsParser::kGpuTestPass);247}248249// A wild character (*) at the end of a line should match any expectations that are a subset of that250// line. It should not greedily match to omany expectations that aren't in that subset.251TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserWildChar)252{253std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP)";254EXPECT_TRUE(load(line));255EXPECT_TRUE(parser.getErrorMessages().empty());256EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),257GPUTestExpectationsParser::kGpuTestSkip);258// Also ensure the wild char is not too wild, only covers tests that are more specific259EXPECT_EQ(get("dEQP-GLES31.functional.program_interface_query.transform_feedback_varying."260"resource_list.vertex_fragment.builtin_gl_position"),261GPUTestExpectationsParser::kGpuTestPass);262}263264// A line without an equals should return an error and not add the expectation.265TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingEquals)266{267std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max SKIP)";268EXPECT_FALSE(load(line));269EXPECT_EQ(parser.getErrorMessages().size(), 1u);270if (parser.getErrorMessages().size() >= 1)271{272EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");273}274// Default behavior is to let missing tests pass275EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),276GPUTestExpectationsParser::kGpuTestPass);277}278279// A line without an expectation should return an error and not add the expectation.280TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMissingExpectation)281{282std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max =)";283EXPECT_FALSE(load(line));284EXPECT_EQ(parser.getErrorMessages().size(), 1u);285if (parser.getErrorMessages().size() >= 1)286{287EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");288}289// Default behavior is to let missing tests pass290EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),291GPUTestExpectationsParser::kGpuTestPass);292}293294// A line with an expectation that doesn't exist should return an error and not add the expectation.295TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserInvalidExpectation)296{297std::string line =298R"(100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = WRONG)";299EXPECT_FALSE(load(line));300EXPECT_EQ(parser.getErrorMessages().size(), 1u);301if (parser.getErrorMessages().size() >= 1)302{303EXPECT_EQ(parser.getErrorMessages()[0], "Line 1 : entry with wrong format");304}305// Default behavior is to let missing tests pass306EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),307GPUTestExpectationsParser::kGpuTestPass);308}309310// ChromeOS is reserved as a token, but doesn't actually check any conditions. Any tokens that311// do not check conditions should return an error and not add the expectation312// (https://anglebug.com/3363) Remove/update this test when ChromeOS is supported313TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserUnimplementedCondition)314{315// Does not apply when loading all expectations and not checking the config.316if (GetParam() == ConditionTestType::OnGet)317{318GTEST_SKIP() << "Test does not apply when loading all expectations.";319}320321std::string line =322R"(100 CHROMEOS : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";323EXPECT_FALSE(load(line));324EXPECT_EQ(parser.getErrorMessages().size(), 1u);325if (parser.getErrorMessages().size() >= 1)326{327EXPECT_EQ(parser.getErrorMessages()[0],328"Line 1 : entry invalid, likely unimplemented modifiers");329}330// Default behavior is to let missing tests pass331EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),332GPUTestExpectationsParser::kGpuTestPass);333}334335// If a line starts with a comment, it's ignored and should not be added to the list.336TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserComment)337{338std::string line =339R"(//100 : dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max = SKIP)";340EXPECT_TRUE(load(line));341EXPECT_TRUE(parser.getErrorMessages().empty());342EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),343GPUTestExpectationsParser::kGpuTestPass);344}345346// A misspelled expectation should not be matched from getTestExpectation, and should lead to an347// unused expectation when later queried.348TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserMisspelledExpectation)349{350std::string line =351R"(100 : dEQP-GLES31.functionaal.layout_binding.ubo.* = SKIP)"; // "functionaal"352EXPECT_TRUE(load(line));353EXPECT_TRUE(parser.getErrorMessages().empty());354// Default behavior is to let missing tests pass355EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),356GPUTestExpectationsParser::kGpuTestPass);357EXPECT_EQ(parser.getUnusedExpectationsMessages().size(), 1u);358if (parser.getUnusedExpectationsMessages().size() >= 1)359{360EXPECT_EQ(parser.getUnusedExpectationsMessages()[0], "Line 1: expectation was unused.");361}362}363364// Wild characters that match groups of expectations can be overridden with more specific lines.365// The parse should still compute correctly which lines were used and which were unused.366TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserOverrideExpectation)367{368// Fail all layout_binding tests, but skip the layout_binding.ubo subset.369std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.* = FAIL370100 : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP)";371EXPECT_TRUE(load(line));372EXPECT_TRUE(parser.getErrorMessages().empty());373// Default behavior is to let missing tests pass374EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),375GPUTestExpectationsParser::kGpuTestSkip);376// The FAIL expectation was unused because it was overridden.377EXPECT_EQ(parser.getUnusedExpectationsMessages().size(), 1u);378if (parser.getUnusedExpectationsMessages().size() >= 1)379{380EXPECT_EQ(parser.getUnusedExpectationsMessages()[0], "Line 1: expectation was unused.");381}382// Now try a test that doesn't match the override criteria383EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.image.test"),384GPUTestExpectationsParser::kGpuTestFail);385EXPECT_TRUE(parser.getUnusedExpectationsMessages().empty());386}387388// This test is the same as GPUTestExpectationsParserOverrideExpectation, but verifying the order389// doesn't matter when overriding.390TEST_P(GPUTestExpectationsParserTest, GPUTestExpectationsParserOverrideExpectationOtherOrder)391{392// Fail all layout_binding tests, but skip the layout_binding.ubo subset.393std::string line = R"(100 : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP394100 : dEQP-GLES31.functional.layout_binding.* = FAIL)";395EXPECT_TRUE(load(line));396EXPECT_TRUE(parser.getErrorMessages().empty());397// Default behavior is to let missing tests pass398EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),399GPUTestExpectationsParser::kGpuTestSkip);400// The FAIL expectation was unused because it was overridden.401EXPECT_EQ(parser.getUnusedExpectationsMessages().size(), 1u);402if (parser.getUnusedExpectationsMessages().size() >= 1)403{404EXPECT_EQ(parser.getUnusedExpectationsMessages()[0], "Line 2: expectation was unused.");405}406// Now try a test that doesn't match the override criteria407EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.image.test"),408GPUTestExpectationsParser::kGpuTestFail);409EXPECT_TRUE(parser.getUnusedExpectationsMessages().empty());410}411412// Tests that overlap checking doesn't generate false positives.413TEST_P(GPUTestExpectationsParserTest, OverlapConditions)414{415std::string lines = R"(416100 NVIDIA VULKAN : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP417100 NVIDIA D3D11 : dEQP-GLES31.functional.layout_binding.ubo.* = SKIP)";418419ASSERT_TRUE(load(lines));420ASSERT_TRUE(parser.getErrorMessages().empty());421422EXPECT_EQ(get("dEQP-GLES31.functional.layout_binding.ubo.vertex_binding_max"),423GPUTestExpectationsParser::kGpuTestSkip);424}425426std::string ConditionTestTypeName(testing::TestParamInfo<ConditionTestType> testParamInfo)427{428if (testParamInfo.param == ConditionTestType::OnLoad)429{430return "OnLoad";431}432else433{434return "OnGet";435}436}437438INSTANTIATE_TEST_SUITE_P(,439GPUTestExpectationsParserTest,440testing::Values(ConditionTestType::OnGet, ConditionTestType::OnLoad),441ConditionTestTypeName);442} // anonymous namespace443444445