• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #ifndef TEST_EXPECTATIONS_GPU_TEST_EXPECTATIONS_PARSER_H_
8 #define TEST_EXPECTATIONS_GPU_TEST_EXPECTATIONS_PARSER_H_
9 
10 #include <stddef.h>
11 #include <stdint.h>
12 
13 #include <string>
14 #include <vector>
15 
16 namespace angle
17 {
18 
19 struct GPUTestConfig;
20 
21 class GPUTestExpectationsParser
22 {
23   public:
24     enum GPUTestExpectation
25     {
26         kGpuTestPass    = 1 << 0,
27         kGpuTestFail    = 1 << 1,
28         kGpuTestFlaky   = 1 << 2,
29         kGpuTestTimeout = 1 << 3,
30         kGpuTestSkip    = 1 << 4,
31     };
32 
33     GPUTestExpectationsParser();
34     ~GPUTestExpectationsParser();
35 
36     // Parse the text expectations, and if no error is encountered,
37     // save all the entries. Otherwise, generate error messages.
38     // Return true if parsing succeeds.
39     bool loadTestExpectations(const GPUTestConfig &config, const std::string &data);
40     bool loadTestExpectationsFromFile(const GPUTestConfig &config, const std::string &path);
41 
42     // Query error messages from the last LoadTestExpectations() call.
43     const std::vector<std::string> &getErrorMessages() const;
44 
45     // Query error messages from any expectations that weren't used before being queried.
46     std::vector<std::string> getUnusedExpectationsMessages() const;
47 
48     // Get the test expectation of a given test on a given bot.
49     int32_t getTestExpectation(const std::string &testName);
50 
51   private:
52     struct GPUTestExpectationEntry
53     {
54         GPUTestExpectationEntry();
55 
56         std::string testName;
57         int32_t testExpectation;
58         size_t lineNumber;
59         bool used;
60     };
61 
62     // Parse a line of text. If we have a valid entry, save it; otherwise,
63     // generate error messages.
64     bool parseLine(const GPUTestConfig &config, const std::string &lineData, size_t lineNumber);
65 
66     // Check a the condition assigned to a particular token.
67     bool checkTokenCondition(const GPUTestConfig &config,
68                              bool &err,
69                              int32_t token,
70                              size_t lineNumber);
71 
72     // Check if two entries' config overlap with each other. May generate an
73     // error message.
74     bool detectConflictsBetweenEntries();
75 
76     // Query a list of any expectations that were's used before being queried.
77     std::vector<GPUTestExpectationEntry> getUnusedExpectations() const;
78 
79     // Save an error message, which can be queried later.
80     void pushErrorMessage(const std::string &message, size_t lineNumber);
81     void pushErrorMessage(const std::string &message,
82                           size_t entry1LineNumber,
83                           size_t entry2LineNumber);
84 
85     std::vector<GPUTestExpectationEntry> mEntries;
86     std::vector<std::string> mErrorMessages;
87 };
88 
89 const char *GetConditionName(uint32_t condition);
90 
91 }  // namespace angle
92 
93 #endif  // TEST_EXPECTATIONS_GPU_TEST_EXPECTATIONS_PARSER_H_
94