xref: /aosp_15_r20/external/deqp/executor/xeTestResultParser.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker #ifndef _XETESTRESULTPARSER_HPP
2*35238bceSAndroid Build Coastguard Worker #define _XETESTRESULTPARSER_HPP
3*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program Test Executor
5*35238bceSAndroid Build Coastguard Worker  * ------------------------------------------
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
8*35238bceSAndroid Build Coastguard Worker  *
9*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
10*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
11*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
14*35238bceSAndroid Build Coastguard Worker  *
15*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
16*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
17*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
19*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
20*35238bceSAndroid Build Coastguard Worker  *
21*35238bceSAndroid Build Coastguard Worker  *//*!
22*35238bceSAndroid Build Coastguard Worker  * \file
23*35238bceSAndroid Build Coastguard Worker  * \brief Test case result parser.
24*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
25*35238bceSAndroid Build Coastguard Worker 
26*35238bceSAndroid Build Coastguard Worker #include "xeDefs.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "xeXMLParser.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "xeTestCaseResult.hpp"
29*35238bceSAndroid Build Coastguard Worker 
30*35238bceSAndroid Build Coastguard Worker #include <vector>
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker namespace xe
33*35238bceSAndroid Build Coastguard Worker {
34*35238bceSAndroid Build Coastguard Worker 
35*35238bceSAndroid Build Coastguard Worker enum TestLogVersion
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker     TESTLOGVERSION_0_2_0 = 0,
38*35238bceSAndroid Build Coastguard Worker     TESTLOGVERSION_0_3_0,
39*35238bceSAndroid Build Coastguard Worker     TESTLOGVERSION_0_3_1,
40*35238bceSAndroid Build Coastguard Worker     TESTLOGVERSION_0_3_2,
41*35238bceSAndroid Build Coastguard Worker     TESTLOGVERSION_0_3_3,
42*35238bceSAndroid Build Coastguard Worker     TESTLOGVERSION_0_3_4,
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker     TESTLOGVERSION_LAST
45*35238bceSAndroid Build Coastguard Worker };
46*35238bceSAndroid Build Coastguard Worker 
47*35238bceSAndroid Build Coastguard Worker class TestResultParseError : public ParseError
48*35238bceSAndroid Build Coastguard Worker {
49*35238bceSAndroid Build Coastguard Worker public:
TestResultParseError(const std::string & message)50*35238bceSAndroid Build Coastguard Worker     TestResultParseError(const std::string &message) : ParseError(message)
51*35238bceSAndroid Build Coastguard Worker     {
52*35238bceSAndroid Build Coastguard Worker     }
53*35238bceSAndroid Build Coastguard Worker };
54*35238bceSAndroid Build Coastguard Worker 
55*35238bceSAndroid Build Coastguard Worker class TestResultParser
56*35238bceSAndroid Build Coastguard Worker {
57*35238bceSAndroid Build Coastguard Worker public:
58*35238bceSAndroid Build Coastguard Worker     enum ParseResult
59*35238bceSAndroid Build Coastguard Worker     {
60*35238bceSAndroid Build Coastguard Worker         PARSERESULT_NOT_CHANGED,
61*35238bceSAndroid Build Coastguard Worker         PARSERESULT_CHANGED,
62*35238bceSAndroid Build Coastguard Worker         PARSERESULT_COMPLETE,
63*35238bceSAndroid Build Coastguard Worker         PARSERESULT_ERROR,
64*35238bceSAndroid Build Coastguard Worker 
65*35238bceSAndroid Build Coastguard Worker         PARSERESULT_LAST
66*35238bceSAndroid Build Coastguard Worker     };
67*35238bceSAndroid Build Coastguard Worker 
68*35238bceSAndroid Build Coastguard Worker     TestResultParser(void);
69*35238bceSAndroid Build Coastguard Worker     ~TestResultParser(void);
70*35238bceSAndroid Build Coastguard Worker 
71*35238bceSAndroid Build Coastguard Worker     void init(TestCaseResult *dstResult);
72*35238bceSAndroid Build Coastguard Worker     ParseResult parse(const uint8_t *bytes, int numBytes);
73*35238bceSAndroid Build Coastguard Worker 
74*35238bceSAndroid Build Coastguard Worker private:
75*35238bceSAndroid Build Coastguard Worker     TestResultParser(const TestResultParser &other);
76*35238bceSAndroid Build Coastguard Worker     TestResultParser &operator=(const TestResultParser &other);
77*35238bceSAndroid Build Coastguard Worker 
78*35238bceSAndroid Build Coastguard Worker     void clear(void);
79*35238bceSAndroid Build Coastguard Worker 
80*35238bceSAndroid Build Coastguard Worker     void handleElementStart(void);
81*35238bceSAndroid Build Coastguard Worker     void handleElementEnd(void);
82*35238bceSAndroid Build Coastguard Worker     void handleData(void);
83*35238bceSAndroid Build Coastguard Worker 
84*35238bceSAndroid Build Coastguard Worker     const char *getAttribute(const char *name);
85*35238bceSAndroid Build Coastguard Worker 
86*35238bceSAndroid Build Coastguard Worker     ri::Item *getCurrentItem(void);
87*35238bceSAndroid Build Coastguard Worker     ri::List *getCurrentItemList(void);
88*35238bceSAndroid Build Coastguard Worker     void pushItem(ri::Item *item);
89*35238bceSAndroid Build Coastguard Worker     void popItem(void);
90*35238bceSAndroid Build Coastguard Worker     void updateCurrentItemList(void);
91*35238bceSAndroid Build Coastguard Worker 
92*35238bceSAndroid Build Coastguard Worker     enum State
93*35238bceSAndroid Build Coastguard Worker     {
94*35238bceSAndroid Build Coastguard Worker         STATE_NOT_INITIALIZED = 0,
95*35238bceSAndroid Build Coastguard Worker         STATE_INITIALIZED,
96*35238bceSAndroid Build Coastguard Worker         STATE_IN_TEST_CASE_RESULT,
97*35238bceSAndroid Build Coastguard Worker         STATE_TEST_CASE_RESULT_ENDED,
98*35238bceSAndroid Build Coastguard Worker 
99*35238bceSAndroid Build Coastguard Worker         STATE_LAST
100*35238bceSAndroid Build Coastguard Worker     };
101*35238bceSAndroid Build Coastguard Worker 
102*35238bceSAndroid Build Coastguard Worker     xml::Parser m_xmlParser;
103*35238bceSAndroid Build Coastguard Worker     TestCaseResult *m_result;
104*35238bceSAndroid Build Coastguard Worker 
105*35238bceSAndroid Build Coastguard Worker     State m_state;
106*35238bceSAndroid Build Coastguard Worker     TestLogVersion m_logVersion; //!< Only valid in STATE_IN_TEST_CASE_RESULT.
107*35238bceSAndroid Build Coastguard Worker 
108*35238bceSAndroid Build Coastguard Worker     std::vector<ri::Item *> m_itemStack;
109*35238bceSAndroid Build Coastguard Worker     ri::List *m_curItemList;
110*35238bceSAndroid Build Coastguard Worker 
111*35238bceSAndroid Build Coastguard Worker     int m_base64DecodeOffset;
112*35238bceSAndroid Build Coastguard Worker 
113*35238bceSAndroid Build Coastguard Worker     std::string m_curNumValue;
114*35238bceSAndroid Build Coastguard Worker };
115*35238bceSAndroid Build Coastguard Worker 
116*35238bceSAndroid Build Coastguard Worker // Helpers exposed to other parsers.
117*35238bceSAndroid Build Coastguard Worker TestStatusCode getTestStatusCode(const char *statusCode);
118*35238bceSAndroid Build Coastguard Worker 
119*35238bceSAndroid Build Coastguard Worker // Parsing helpers.
120*35238bceSAndroid Build Coastguard Worker 
121*35238bceSAndroid Build Coastguard Worker class TestCaseResultData;
122*35238bceSAndroid Build Coastguard Worker 
123*35238bceSAndroid Build Coastguard Worker void parseTestCaseResultFromData(TestResultParser *parser, TestCaseResult *result, const TestCaseResultData &data);
124*35238bceSAndroid Build Coastguard Worker 
125*35238bceSAndroid Build Coastguard Worker } // namespace xe
126*35238bceSAndroid Build Coastguard Worker 
127*35238bceSAndroid Build Coastguard Worker #endif // _XETESTRESULTPARSER_HPP
128