am 3894a568: Merge "Remove flush_wait test as glFlush does not flush on all platforms...
[platform/upstream/VK-GL-CTS.git] / executor / xeContainerFormatParser.hpp
1 #ifndef _XECONTAINERFORMATPARSER_HPP
2 #define _XECONTAINERFORMATPARSER_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Test Executor
5  * ------------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief Test log container format parser.
24  *//*--------------------------------------------------------------------*/
25
26 #include "xeDefs.hpp"
27 #include "deRingBuffer.hpp"
28
29 namespace xe
30 {
31
32 enum ContainerElement
33 {
34         CONTAINERELEMENT_INCOMPLETE = 0,
35         CONTAINERELEMENT_END_OF_STRING,
36         CONTAINERELEMENT_BEGIN_SESSION,
37         CONTAINERELEMENT_END_SESSION,
38         CONTAINERELEMENT_SESSION_INFO,
39         CONTAINERELEMENT_BEGIN_TEST_CASE_RESULT,
40         CONTAINERELEMENT_END_TEST_CASE_RESULT,
41         CONTAINERELEMENT_TERMINATE_TEST_CASE_RESULT,
42         CONTAINERELEMENT_TEST_LOG_DATA,
43
44         CONTAINERELEMENT_LAST
45 };
46
47 class ContainerParseError : public ParseError
48 {
49 public:
50         ContainerParseError (const std::string& message) : ParseError(message) {}
51 };
52
53 class ContainerFormatParser
54 {
55 public:
56                                                                 ContainerFormatParser           (void);
57                                                                 ~ContainerFormatParser          (void);
58
59         void                                            clear                                           (void);
60
61         void                                            feed                                            (const deUint8* bytes, size_t numBytes);
62         void                                            advance                                         (void);
63
64         ContainerElement                        getElement                                      (void) const { return m_element; }
65
66         // SESSION_INFO
67         const char*                                     getSessionInfoAttribute         (void) const;
68         const char*                                     getSessionInfoValue                     (void) const;
69
70         // BEGIN_TEST_CASE
71         const char*                                     getTestCasePath                         (void) const;
72
73         // TERMINATE_TEST_CASE
74         const char*                                     getTerminateReason                      (void) const;
75
76         // TEST_LOG_DATA
77         int                                                     getDataSize                                     (void) const;
78         void                                            getData                                         (deUint8* dst, int numBytes, int offset);
79
80 private:
81                                                                 ContainerFormatParser           (const ContainerFormatParser& other);
82         ContainerFormatParser&          operator=                                       (const ContainerFormatParser& other);
83
84         void                                            error                                           (const std::string& what);
85
86         enum State
87         {
88                 STATE_AT_LINE_START,
89                 STATE_CONTAINER_LINE,
90                 STATE_DATA,
91
92                 STATE_LAST
93         };
94
95         enum
96         {
97                 END_OF_STRING   = 0,                    //!< End of string (0).
98                 END_OF_BUFFER   = 0xffffffff    //!< End of current data buffer.
99         };
100
101         int                                                     getChar                                         (int offset) const;
102         void                                            parseContainerLine                      (void);
103         void                                            parseContainerValue                     (std::string& dst, int& offset) const;
104
105         ContainerElement                        m_element;
106         int                                                     m_elementLen;
107         State                                           m_state;
108         std::string                                     m_attribute;
109         std::string                                     m_value;
110
111         de::RingBuffer<deUint8>         m_buf;
112 };
113
114 } // xe
115
116 #endif // _XECONTAINERFORMATPARSER_HPP