xref: /aosp_15_r20/external/deqp/external/openglcts/modules/runner/glcTestRunner.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _GLCTESTRUNNER_HPP
2 #define _GLCTESTRUNNER_HPP
3 /*-------------------------------------------------------------------------
4  * OpenGL Conformance Test Suite
5  * -----------------------------
6  *
7  * Copyright (c) 2016 Google Inc.
8  * Copyright (c) 2016 The Khronos Group Inc.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *      http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */ /*!
23  * \file
24  * \brief CTS runner.
25  */ /*-------------------------------------------------------------------*/
26 
27 #include "gluPlatform.hpp"
28 #include "tcuDefs.hpp"
29 #include "tcuTestPackage.hpp"
30 
31 #include <string>
32 #include <vector>
33 
34 namespace tcu
35 {
36 
37 class Archive;
38 
39 } // namespace tcu
40 
41 namespace glcts
42 {
43 
44 struct Config;
45 
46 struct RunParams
47 {
48     glu::ApiType apiType;
49     const char *configName;
50     const char *glConfigName;
51     const char *screenRotation;
52     int baseSeed;
53     const char *fboConfig;
54     int surfaceWidth;
55     int surfaceHeight;
56 };
57 
58 struct TestRunParams
59 {
60     std::vector<std::string> args;
61     std::string logFilename;
62 };
63 
64 // Conformance test run summary - written to cts-run-summary.xml
65 struct TestRunSummary
66 {
67     glu::ApiType runType;
68     bool isConformant;
69     std::string configLogFilename;
70     std::vector<TestRunParams> runParams;
71     std::vector<tcu::TestRunStatus> results;
72 
TestRunSummaryglcts::TestRunSummary73     TestRunSummary(void) : isConformant(false)
74     {
75     }
76 
clearglcts::TestRunSummary77     void clear(void)
78     {
79         runType      = glu::ApiType();
80         isConformant = false;
81         configLogFilename.clear();
82         runParams.clear();
83         results.clear();
84     }
85 };
86 
87 class RunSession;
88 
89 class TestRunner
90 {
91 public:
92     enum Flags
93     {
94         VERBOSE_COMMANDS = (1 << 0),
95         VERBOSE_IMAGES   = (1 << 1),
96         VERBOSE_SHADERS  = (1 << 2),
97 
98         VERBOSE_ALL = VERBOSE_COMMANDS | VERBOSE_IMAGES,
99 
100         PRINT_SUMMARY = (1 << 3)
101     };
102 
103     TestRunner(tcu::Platform &platform, tcu::Archive &archive, const char *waiverPath, const char *logDirPath,
104                glu::ApiType type, uint32_t flags);
105     ~TestRunner(void);
106 
107     bool iterate(void);
isConformant() const108     bool isConformant() const
109     {
110         return m_summary.isConformant;
111     }
112 
113 private:
114     TestRunner(const TestRunner &other);
115     TestRunner operator=(const TestRunner &other);
116 
117     void init(void);
118     void deinit(void);
119 
120     void initSession(const TestRunParams &runParams);
121     void deinitSession(void);
122     bool iterateSession(void);
123 
124     enum IterateState
125     {
126         ITERATE_INIT = 0, //!< Call init() on this iteration.
127         ITERATE_DEINIT,   //!< Call deinit() on this iteration.
128 
129         ITERATE_INIT_SESSION,    //!< Init current session.
130         ITERATE_DEINIT_SESSION,  //!< Deinit session and move to next.
131         ITERATE_ITERATE_SESSION, //!< Iterate current session.
132 
133         ITERATESTATE_LAST
134     };
135 
136     tcu::Platform &m_platform;
137     tcu::Archive &m_archive;
138     std::string m_waiverPath;
139     std::string m_logDirPath;
140     glu::ApiType m_type;
141     uint32_t m_flags;
142 
143     // Iteration state.
144     IterateState m_iterState;
145     std::vector<TestRunParams> m_runSessions;
146     std::vector<TestRunParams>::const_iterator m_sessionIter;
147     RunSession *m_curSession;
148 
149     // Totals / stats.
150     int m_sessionsExecuted;
151     int m_sessionsPassed;
152     int m_sessionsFailed;
153     TestRunSummary m_summary;
154 };
155 
156 class TestParamCollectorRunner
157 {
158 public:
159     TestParamCollectorRunner(tcu::Platform &platform, const char *testParamsFilePath, glu::ApiType type);
160     ~TestParamCollectorRunner(void);
161 
162     bool iterate(void);
163 
164 private:
165     TestParamCollectorRunner(const TestRunner &other);
166     TestParamCollectorRunner operator=(const TestRunner &other);
167 
168     tcu::Platform &m_platform;
169     std::string m_testParamsFilePath;
170     glu::ApiType m_type;
171 
172     std::vector<TestRunParams> m_runSessionsParams;
173 };
174 
175 } // namespace glcts
176 
177 #endif // _GLCTESTRUNNER_HPP
178