be59095ecfd580fd2aefd9e16d570f9e006d9c12
[platform/upstream/VK-GL-CTS.git] / external / openglcts / modules / runner / glcTestRunner.hpp
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
30 #include <string>
31 #include <vector>
32
33 namespace tcu
34 {
35
36 class Archive;
37
38 } // tcu
39
40 namespace glcts
41 {
42
43 struct Config;
44
45 struct TestRunParams
46 {
47         std::vector<std::string> args;
48         std::string                              logFilename;
49 };
50
51 // Conformance test run summary - written to cts-run-summary.xml
52 struct TestRunSummary
53 {
54         glu::ApiType                       runType;
55         bool                                       isConformant;
56         std::string                                configLogFilename;
57         std::vector<TestRunParams> runParams;
58
59         TestRunSummary(void) : isConformant(false)
60         {
61         }
62
63         void clear(void)
64         {
65                 runType          = glu::ApiType();
66                 isConformant = false;
67                 configLogFilename.clear();
68                 runParams.clear();
69         }
70 };
71
72 class RunSession;
73
74 class TestRunner
75 {
76 public:
77         enum Flags
78         {
79                 VERBOSE_COMMANDS = (1 << 0),
80                 VERBOSE_IMAGES   = (1 << 1),
81                 VERBOSE_SHADERS  = (1 << 2),
82
83                 VERBOSE_ALL = VERBOSE_COMMANDS | VERBOSE_IMAGES,
84
85                 PRINT_SUMMARY = (1 << 3)
86         };
87
88         TestRunner(tcu::Platform& platform, tcu::Archive& archive, const char* logDirPath, glu::ApiType type,
89                            deUint32 flags);
90         ~TestRunner(void);
91
92         bool iterate(void);
93
94 private:
95         TestRunner(const TestRunner& other);
96         TestRunner operator=(const TestRunner& other);
97
98         void init(void);
99         void deinit(void);
100
101         void initSession(const TestRunParams& runParams);
102         void deinitSession(void);
103         bool iterateSession(void);
104
105         enum IterateState
106         {
107                 ITERATE_INIT = 0, //!< Call init() on this iteration.
108                 ITERATE_DEINIT,   //!< Call deinit() on this iteration.
109
110                 ITERATE_INIT_SESSION,   //!< Init current session.
111                 ITERATE_DEINIT_SESSION,  //!< Deinit session and move to next.
112                 ITERATE_ITERATE_SESSION, //!< Iterate current session.
113
114                 ITERATESTATE_LAST
115         };
116
117         tcu::Platform& m_platform;
118         tcu::Archive&  m_archive;
119         std::string     m_logDirPath;
120         glu::ApiType   m_type;
121         deUint32           m_flags;
122
123         // Iteration state.
124         IterateState                                                       m_iterState;
125         std::vector<TestRunParams>                                 m_runSessions;
126         std::vector<TestRunParams>::const_iterator m_sessionIter;
127         RunSession*                                                                m_curSession;
128
129         // Totals / stats.
130         int                        m_sessionsExecuted;
131         int                        m_sessionsPassed;
132         int                        m_sessionsFailed;
133         TestRunSummary m_summary;
134 };
135
136 } // glcts
137
138 #endif // _GLCTESTRUNNER_HPP