diff options
author | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 05:06:08 +0000 |
---|---|---|
committer | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 05:06:08 +0000 |
commit | 830631c03aaeb418faf2dac3cf9e8424a84d8d0d (patch) | |
tree | e85eec947944417ae14bca5b82bcdfae105200cd /content/test/gpu | |
parent | 0ebd5f48f8af65401e916be4ead925d1c51277b1 (diff) | |
download | chromium_src-830631c03aaeb418faf2dac3cf9e8424a84d8d0d.zip chromium_src-830631c03aaeb418faf2dac3cf9e8424a84d8d0d.tar.gz chromium_src-830631c03aaeb418faf2dac3cf9e8424a84d8d0d.tar.bz2 |
Add a static function for easy test bot config specification.
BUG=
TEST=gpu related tests
R=jbates
Review URL: https://chromiumcodereview.appspot.com/10545144
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/test/gpu')
-rw-r--r-- | content/test/gpu/gpu_test_config.cc | 31 | ||||
-rw-r--r-- | content/test/gpu/gpu_test_config.h | 6 | ||||
-rw-r--r-- | content/test/gpu/gpu_test_config_unittest.cc | 31 | ||||
-rw-r--r-- | content/test/gpu/gpu_test_expectations_parser.cc | 45 | ||||
-rw-r--r-- | content/test/gpu/gpu_test_expectations_parser.h | 4 | ||||
-rw-r--r-- | content/test/gpu/gpu_test_expectations_parser_unittest.cc | 4 |
6 files changed, 119 insertions, 2 deletions
diff --git a/content/test/gpu/gpu_test_config.cc b/content/test/gpu/gpu_test_config.cc index b76debe..b6744ce 100644 --- a/content/test/gpu/gpu_test_config.cc +++ b/content/test/gpu/gpu_test_config.cc @@ -8,6 +8,7 @@ #include "base/sys_info.h" #include "content/gpu/gpu_info_collector.h" #include "content/public/common/gpu_info.h" +#include "content/test/gpu/gpu_test_expectations_parser.h" namespace { @@ -189,6 +190,15 @@ bool GPUTestBotConfig::Matches(const GPUTestConfig& config) const { return true; } +bool GPUTestBotConfig::Matches(const std::string& config_data) const { + GPUTestExpectationsParser parser; + GPUTestConfig config; + + if (!parser.ParseConfig(config_data, &config)) + return false; + return Matches(config); +} + bool GPUTestBotConfig::LoadCurrentConfig(const content::GPUInfo* gpu_info) { bool rt; if (gpu_info == NULL) { @@ -209,3 +219,24 @@ bool GPUTestBotConfig::LoadCurrentConfig(const content::GPUInfo* gpu_info) { return rt; } +// static +bool GPUTestBotConfig::CurrentConfigMatches(const std::string& config_data) { + GPUTestBotConfig my_config; + if (!my_config.LoadCurrentConfig(NULL)) + return false; + return my_config.Matches(config_data); +} + +// static +bool GPUTestBotConfig::CurrentConfigMatches( + const std::vector<std::string>& configs) { + GPUTestBotConfig my_config; + if (!my_config.LoadCurrentConfig(NULL)) + return false; + for (size_t i = 0 ; i < configs.size(); ++i) { + if (my_config.Matches(configs[i])) + return true; + } + return false; +} + diff --git a/content/test/gpu/gpu_test_config.h b/content/test/gpu/gpu_test_config.h index 4c14d0f..53f78a2 100644 --- a/content/test/gpu/gpu_test_config.h +++ b/content/test/gpu/gpu_test_config.h @@ -6,6 +6,7 @@ #define CONTENT_TEST_GPU_GPU_TEST_CONFIG_H_ #pragma once +#include <string> #include <vector> #include "base/basictypes.h" @@ -95,10 +96,15 @@ class GPUTestBotConfig : public GPUTestConfig { // Check if a bot config matches a test config, i.e., the test config is a // superset of the bot config. bool Matches(const GPUTestConfig& config) const; + bool Matches(const std::string& config_data) const; // Setup the config with the current gpu testing environment. // If gpu_info is NULL, collect GPUInfo first. bool LoadCurrentConfig(const content::GPUInfo* gpu_info); + + // Check if this bot's config matches |config_data| or any of the |configs|. + static bool CurrentConfigMatches(const std::string& config_data); + static bool CurrentConfigMatches(const std::vector<std::string>& configs); }; #endif // CONTENT_TEST_GPU_GPU_TEST_CONFIG_H_ diff --git a/content/test/gpu/gpu_test_config_unittest.cc b/content/test/gpu/gpu_test_config_unittest.cc index 6f47b64..5abcfdb 100644 --- a/content/test/gpu/gpu_test_config_unittest.cc +++ b/content/test/gpu/gpu_test_config_unittest.cc @@ -140,6 +140,37 @@ TEST_F(GPUTestConfigTest, Matches) { } } +TEST_F(GPUTestConfigTest, StringMatches) { + GPUTestBotConfig config; + config.set_os(GPUTestConfig::kOsWin7); + config.set_build_type(GPUTestConfig::kBuildTypeRelease); + config.AddGPUVendor(0x10de); + config.set_gpu_device_id(0x0640); + EXPECT_TRUE(config.IsValid()); + + EXPECT_TRUE(config.Matches("")); + + // os matching + EXPECT_TRUE(config.Matches("WIN")); + EXPECT_TRUE(config.Matches("WIN7")); + EXPECT_FALSE(config.Matches("MAC")); + EXPECT_TRUE(config.Matches("WIN7 LINUX")); + + // gpu vendor matching + EXPECT_TRUE(config.Matches("NVIDIA")); + EXPECT_TRUE(config.Matches("NVIDIA AMD")); + EXPECT_FALSE(config.Matches("INTEL")); + + // build type matching + EXPECT_TRUE(config.Matches("RELEASE")); + EXPECT_TRUE(config.Matches("RELEASE DEBUG")); + EXPECT_FALSE(config.Matches("DEBUG")); + + // exact matching + EXPECT_TRUE(config.Matches("WIN7 RELEASE NVIDIA 0X0640")); + EXPECT_FALSE(config.Matches("WIN7 RELEASE NVIDIA 0X0641")); +} + TEST_F(GPUTestConfigTest, OverlapsWith) { { // os // win vs win7 diff --git a/content/test/gpu/gpu_test_expectations_parser.cc b/content/test/gpu/gpu_test_expectations_parser.cc index 80e1246..bc14b72 100644 --- a/content/test/gpu/gpu_test_expectations_parser.cc +++ b/content/test/gpu/gpu_test_expectations_parser.cc @@ -41,6 +41,7 @@ enum Token { kConfigNVidia, kConfigAMD, kConfigIntel, + kConfigVMWare, // build type kConfigRelease, kConfigDebug, @@ -81,6 +82,7 @@ const TokenInfo kTokenData[] = { { "nvidia", 0x10DE }, { "amd", 0x1002 }, { "intel", 0x8086 }, + { "vmware", 0x15ad }, { "release", GPUTestConfig::kBuildTypeRelease }, { "debug", GPUTestConfig::kBuildTypeDebug }, { "pass", GPUTestExpectationsParser::kGpuTestPass }, @@ -213,6 +215,47 @@ GPUTestExpectationsParser::GetErrorMessages() const { return error_messages_; } +bool GPUTestExpectationsParser::ParseConfig( + const std::string& config_data, GPUTestConfig* config) { + DCHECK(config); + std::vector<std::string> tokens; + base::SplitStringAlongWhitespace(config_data, &tokens); + + for (size_t i = 0; i < tokens.size(); ++i) { + Token token = ParseToken(tokens[i]); + switch (token) { + case kConfigWinXP: + case kConfigWinVista: + case kConfigWin7: + case kConfigWin: + case kConfigMacLeopard: + case kConfigMacSnowLeopard: + case kConfigMacLion: + case kConfigMac: + case kConfigLinux: + case kConfigChromeOS: + case kConfigNVidia: + case kConfigAMD: + case kConfigIntel: + case kConfigVMWare: + case kConfigRelease: + case kConfigDebug: + case kConfigGPUDeviceID: + if (token == kConfigGPUDeviceID) { + if (!UpdateTestConfig(config, tokens[i], 0)) + return false; + } else { + if (!UpdateTestConfig(config, token, 0)) + return false; + } + break; + default: + return false; + } + } + return true; +} + bool GPUTestExpectationsParser::ParseLine( const std::string& line_data, size_t line_number) { std::vector<std::string> tokens; @@ -241,6 +284,7 @@ bool GPUTestExpectationsParser::ParseLine( case kConfigNVidia: case kConfigAMD: case kConfigIntel: + case kConfigVMWare: case kConfigRelease: case kConfigDebug: case kConfigGPUDeviceID: @@ -357,6 +401,7 @@ bool GPUTestExpectationsParser::UpdateTestConfig( case kConfigNVidia: case kConfigAMD: case kConfigIntel: + case kConfigVMWare: { uint32 gpu_vendor = static_cast<uint32>(kTokenData[token].flag); diff --git a/content/test/gpu/gpu_test_expectations_parser.h b/content/test/gpu/gpu_test_expectations_parser.h index b49daf2..10371c5 100644 --- a/content/test/gpu/gpu_test_expectations_parser.h +++ b/content/test/gpu/gpu_test_expectations_parser.h @@ -44,6 +44,10 @@ class GPUTestExpectationsParser { int32 GetTestExpectation(const std::string& test_name, const GPUTestBotConfig& bot_config) const; + // Parse a list of config modifiers. If we have a valid entry with no + // conflicts, | config | stores it, and the function returns true. + bool ParseConfig(const std::string& config_data, GPUTestConfig* config); + private: struct GPUTestExpectationEntry { GPUTestExpectationEntry(); diff --git a/content/test/gpu/gpu_test_expectations_parser_unittest.cc b/content/test/gpu/gpu_test_expectations_parser_unittest.cc index 430dfb9c..d034797 100644 --- a/content/test/gpu/gpu_test_expectations_parser_unittest.cc +++ b/content/test/gpu/gpu_test_expectations_parser_unittest.cc @@ -90,7 +90,7 @@ TEST_F(GPUTestExpectationsParserTest, ValidUnrelatedTestEntry) { TEST_F(GPUTestExpectationsParserTest, AllModifiers) { const std::string text = "BUG12345 XP VISTA WIN7 LEOPARD SNOWLEOPARD LION LINUX CHROMEOS " - "NVIDIA INTEL AMD RELEASE DEBUG : MyTest = " + "NVIDIA INTEL AMD VMWARE RELEASE DEBUG : MyTest = " "PASS FAIL FLAKY TIMEOUT SKIP"; GPUTestExpectationsParser parser; @@ -116,7 +116,7 @@ TEST_F(GPUTestExpectationsParserTest, DuplicateModifiers) { TEST_F(GPUTestExpectationsParserTest, AllModifiersLowerCase) { const std::string text = "BUG12345 xp vista win7 leopard snowleopard lion linux chromeos " - "nvidia intel amd release debug : MyTest = " + "nvidia intel amd vmware release debug : MyTest = " "pass fail flaky timeout skip"; GPUTestExpectationsParser parser; |