Add CTS_ARB_gl_spirv test implementation
[platform/upstream/VK-GL-CTS.git] / executor / xeBatchExecutor.hpp
1 #ifndef _XEBATCHEXECUTOR_HPP
2 #define _XEBATCHEXECUTOR_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 batch executor.
24  *//*--------------------------------------------------------------------*/
25
26 #include "xeDefs.hpp"
27 #include "xeBatchResult.hpp"
28 #include "xeCommLink.hpp"
29 #include "xeTestLogParser.hpp"
30 #include "xeCallQueue.hpp"
31
32 #include <string>
33 #include <vector>
34
35 namespace xe
36 {
37
38 struct TargetConfiguration
39 {
40         TargetConfiguration (void)
41                 : maxCasesPerSession(1000)
42         {
43         }
44
45         std::string             binaryName;
46         std::string             workingDir;
47         std::string             cmdLineArgs;
48         int                             maxCasesPerSession;
49 };
50
51 class BatchExecutorLogHandler : public TestLogHandler
52 {
53 public:
54                                                         BatchExecutorLogHandler         (BatchResult* batchResult);
55                                                         ~BatchExecutorLogHandler        (void);
56
57         void                                    setSessionInfo                          (const SessionInfo& sessionInfo);
58
59         TestCaseResultPtr               startTestCaseResult                     (const char* casePath);
60         void                                    testCaseResultUpdated           (const TestCaseResultPtr& resultData);
61         void                                    testCaseResultComplete          (const TestCaseResultPtr& resultData);
62
63 private:
64         BatchResult*                    m_batchResult;
65 };
66
67 class BatchExecutor
68 {
69 public:
70                                                         BatchExecutor           (const TargetConfiguration& config, CommLink* commLink, const TestNode* root, const TestSet& testSet, BatchResult* batchResult, InfoLog* infoLog);
71                                                         ~BatchExecutor          (void);
72
73         void                                    run                                     (void);
74         void                                    cancel                          (void); //!< Cancel current run(), can be called from any thread.
75
76 private:
77                                                         BatchExecutor           (const BatchExecutor& other);
78         BatchExecutor&                  operator=                       (const BatchExecutor& other);
79
80         bool                                    iterate                         (void);
81
82         void                                    onStateChanged          (CommLinkState state, const char* message);
83         void                                    onTestLogData           (const deUint8* bytes, size_t numBytes);
84         void                                    onInfoLogData           (const deUint8* bytes, size_t numBytes);
85
86         void                                    launchTestSet           (const TestSet& testSet);
87
88         // Callbacks for CommLink.
89         static void                             enqueueStateChanged     (void* userPtr, CommLinkState state, const char* message);
90         static void                             enqueueTestLogData      (void* userPtr, const deUint8* bytes, size_t numBytes);
91         static void                             enqueueInfoLogData      (void* userPtr, const deUint8* bytes, size_t numBytes);
92
93         // Called in CallQueue dispatch.
94         static void                             dispatchStateChanged    (CallReader& data);
95         static void                             dispatchTestLogData             (CallReader& data);
96         static void                             dispatchInfoLogData             (CallReader& data);
97
98         enum State
99         {
100                 STATE_NOT_STARTED,
101                 STATE_STARTED,
102                 STATE_FINISHED,
103
104                 STATE_LAST
105         };
106
107         TargetConfiguration             m_config;
108         CommLink*                               m_commLink;
109
110         const TestNode*                 m_root;
111         const TestSet&                  m_testSet;
112
113         BatchExecutorLogHandler m_logHandler;
114         BatchResult*                    m_batchResult;
115         InfoLog*                                m_infoLog;
116
117         State                                   m_state;
118         TestSet                                 m_casesToExecute;
119
120         TestLogParser                   m_testLogParser;
121
122         CallQueue                               m_dispatcher;
123 };
124
125 } // xe
126
127 #endif // _XEBATCHEXECUTOR_HPP