gpu_test_expectations_parser.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef GPU_CONFIG_GPU_TEST_EXPECTATIONS_PARSER_H_
  5. #define GPU_CONFIG_GPU_TEST_EXPECTATIONS_PARSER_H_
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <string>
  9. #include <vector>
  10. #include "base/files/file_path.h"
  11. #include "gpu/config/gpu_test_config.h"
  12. #include "gpu/gpu_export.h"
  13. namespace gpu {
  14. class GPU_EXPORT GPUTestExpectationsParser {
  15. public:
  16. enum GPUTestExpectation {
  17. kGpuTestPass = 1 << 0,
  18. kGpuTestFail = 1 << 1,
  19. kGpuTestFlaky = 1 << 2,
  20. kGpuTestTimeout = 1 << 3,
  21. kGpuTestSkip = 1 << 4,
  22. };
  23. GPUTestExpectationsParser();
  24. ~GPUTestExpectationsParser();
  25. // Parse the text expectations, and if no error is encountered,
  26. // save all the entries. Otherwise, generate error messages.
  27. // Return true if parsing succeeds.
  28. bool LoadTestExpectations(const std::string& data);
  29. bool LoadTestExpectations(const base::FilePath& path);
  30. // Query error messages from the last LoadTestExpectations() call.
  31. const std::vector<std::string>& GetErrorMessages() const;
  32. // Get the test expectation of a given test on a given bot.
  33. int32_t GetTestExpectation(const std::string& test_name,
  34. const GPUTestBotConfig& bot_config) const;
  35. // Parse a list of config modifiers. If we have a valid entry with no
  36. // conflicts, | config | stores it, and the function returns true.
  37. bool ParseConfig(const std::string& config_data, GPUTestConfig* config);
  38. private:
  39. struct GPUTestExpectationEntry {
  40. GPUTestExpectationEntry();
  41. std::string test_name;
  42. GPUTestConfig test_config;
  43. int32_t test_expectation;
  44. size_t line_number;
  45. };
  46. // Parse a line of text. If we have a valid entry, save it; otherwise,
  47. // generate error messages.
  48. bool ParseLine(const std::string& line_data, size_t line_number);
  49. // Update OS/GPUVendor/BuildType modifiers. May generate an error message.
  50. bool UpdateTestConfig(GPUTestConfig* config,
  51. int32_t token,
  52. size_t line_number);
  53. // Update GPUDeviceID modifier. May generate an error message.
  54. bool UpdateTestConfig(GPUTestConfig* config,
  55. const std::string & gpu_device_id,
  56. size_t line_number);
  57. // Check if two entries' config overlap with each other. May generate an
  58. // error message.
  59. bool DetectConflictsBetweenEntries();
  60. // Save an error message, which can be queried later.
  61. void PushErrorMessage(const std::string& message, size_t line_number);
  62. void PushErrorMessage(const std::string& message,
  63. size_t entry1_line_number,
  64. size_t entry2_line_number);
  65. std::vector<GPUTestExpectationEntry> entries_;
  66. std::vector<std::string> error_messages_;
  67. };
  68. } // namespace gpu
  69. #endif // GPU_CONFIG_GPU_TEST_EXPECTATIONS_PARSER_H_