Path: blob/main_old/src/tests/test_expectations/GPUTestExpectationsParser.h
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//56#ifndef TEST_EXPECTATIONS_GPU_TEST_EXPECTATIONS_PARSER_H_7#define TEST_EXPECTATIONS_GPU_TEST_EXPECTATIONS_PARSER_H_89#include <stddef.h>10#include <stdint.h>1112#include <string>13#include <vector>1415#include "GPUTestConfig.h"1617namespace angle18{19struct GPUTestConfig;2021class GPUTestExpectationsParser22{23public:24enum GPUTestExpectation25{26kGpuTestPass = 1 << 0,27kGpuTestFail = 1 << 1,28kGpuTestFlaky = 1 << 2,29kGpuTestTimeout = 1 << 3,30kGpuTestSkip = 1 << 4,31};3233GPUTestExpectationsParser();34~GPUTestExpectationsParser();3536// 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.39bool loadTestExpectations(const GPUTestConfig &config, const std::string &data);40bool loadTestExpectationsFromFile(const GPUTestConfig &config, const std::string &path);41bool loadAllTestExpectations(const std::string &data);42bool loadAllTestExpectationsFromFile(const std::string &path);4344// Query error messages from the last LoadTestExpectations() call.45const std::vector<std::string> &getErrorMessages() const;4647// Query error messages from any expectations that weren't used before being queried.48std::vector<std::string> getUnusedExpectationsMessages() const;4950// Get the test expectation of a given test on a given bot.51int32_t getTestExpectation(const std::string &testName);52int32_t getTestExpectationWithConfig(const GPUTestConfig &config, const std::string &testName);53void setTestExpectationsAllowMask(uint32_t mask) { mExpectationsAllowMask = mask; }5455private:56struct GPUTestExpectationEntry57{58GPUTestExpectationEntry();5960std::string testName;61int32_t testExpectation;62size_t lineNumber;63bool used;64GPUTestConfig::ConditionArray conditions;65};6667// Parse a line of text. If we have a valid entry, save it; otherwise,68// generate error messages.69bool parseLine(const GPUTestConfig *config, const std::string &lineData, size_t lineNumber);7071// Check a the condition assigned to a particular token.72bool checkTokenCondition(const GPUTestConfig &config,73bool &err,74int32_t token,75size_t lineNumber);7677// Check if two entries' config overlap with each other. May generate an78// error message.79bool detectConflictsBetweenEntries();8081// Query a list of any expectations that were's used before being queried.82std::vector<GPUTestExpectationEntry> getUnusedExpectations() const;8384// Save an error message, which can be queried later.85void pushErrorMessage(const std::string &message, size_t lineNumber);86void pushErrorMessage(const std::string &message,87size_t entry1LineNumber,88size_t entry2LineNumber);8990// Config is optional.91bool loadTestExpectationsFromFileImpl(const GPUTestConfig *config, const std::string &path);92bool loadTestExpectationsImpl(const GPUTestConfig *config, const std::string &data);9394int32_t getTestExpectationImpl(const GPUTestConfig *config, const std::string &testName);9596std::vector<GPUTestExpectationEntry> mEntries;97std::vector<std::string> mErrorMessages;9899uint32_t mExpectationsAllowMask;100};101102const char *GetConditionName(uint32_t condition);103104} // namespace angle105106#endif // TEST_EXPECTATIONS_GPU_TEST_EXPECTATIONS_PARSER_H_107108109