xref: /aosp_15_r20/external/deqp/framework/qphelper/qpTestLog.h (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 #ifndef _QPTESTLOG_H
2 #define _QPTESTLOG_H
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Helper Library
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  * \defgroup TestLog
23  * \ingroup TestLog
24  * \{
25  * \file
26  * \brief Test log library
27  *
28  * qpTestLog Conventions:
29  *
30  * Each function takes qpTestLog pointer. Operations are done on that log
31  * instance.
32  *
33  * When function takes a 'name' parameter, that name is expected to
34  * be a unique identifier within the scope of one test case. Test case
35  * begins with a call to qpTestLog_startCase and ends with a call to
36  * qpTestLog_endCase or qpTestLog_terminateCase. The human readable
37  * "name" for a piece of information is given with the parameter
38  * called 'description'.
39  *
40  * All functions writing to the log return a boolean value. False
41  * means that the current write operation failed and the current log
42  * instance should be abandoned.
43  *
44  *//*--------------------------------------------------------------------*/
45 
46 #include "deDefs.h"
47 
48 typedef struct qpTestLog_s qpTestLog;
49 
50 /* Test results supported by current report version */
51 /* \note Keep in sync with TestCaseStatus in Candy project. */
52 typedef enum qpTestResult_e
53 {
54     QP_TEST_RESULT_PASS =
55         0,               /*!< Test case passed.                                                                    */
56     QP_TEST_RESULT_FAIL, /*!< Implementation produced incorrect results                                            */
57     QP_TEST_RESULT_QUALITY_WARNING, /*!< Result is within specification, but is not of high quality                            */
58     QP_TEST_RESULT_COMPATIBILITY_WARNING, /*!< Result is within specification, but likely to cause fragmentation in the market    */
59     QP_TEST_RESULT_PENDING, /*!< The test is still running. Not a valid end result                                    */
60     QP_TEST_RESULT_NOT_SUPPORTED, /*!< Implementation does not support functionality needed by this test case                */
61     QP_TEST_RESULT_RESOURCE_ERROR, /*!< Implementation fails to pass the test due to lack of resources                        */
62     QP_TEST_RESULT_INTERNAL_ERROR, /*!< Error occurred within Tester Core                                                    */
63     QP_TEST_RESULT_CRASH,   /*!< Crash occurred in test execution.                                                    */
64     QP_TEST_RESULT_TIMEOUT, /*!< Timeout occurred in test execution.                                                */
65     QP_TEST_RESULT_WAIVER,  /*!< Status code reported by waived test.                                                */
66     QP_TEST_RESULT_DEVICE_LOST, /*!< Test caused a Device Lost error                                                    */
67 
68     QP_TEST_RESULT_LAST
69 } qpTestResult;
70 
71 /* Test case types. */
72 typedef enum qpTestCaseType_e
73 {
74     QP_TEST_CASE_TYPE_SELF_VALIDATE = 0, /*!< Self-validating test case            */
75     QP_TEST_CASE_TYPE_PERFORMANCE,       /*!< Performace test case                */
76     QP_TEST_CASE_TYPE_CAPABILITY,        /*!< Capability score case                */
77     QP_TEST_CASE_TYPE_ACCURACY,          /*!< Accuracy test case                    */
78 
79     QP_TEST_CASE_TYPE_LAST
80 } qpTestCaseType;
81 
82 /*--------------------------------------------------------------------*//*!
83  * \brief Tag key-value pairs to give cues on proper visualization in GUI
84  *//*--------------------------------------------------------------------*/
85 typedef enum qpKeyValueTag_e
86 {
87     QP_KEY_TAG_NONE = 0,
88     QP_KEY_TAG_PERFORMANCE,
89     QP_KEY_TAG_QUALITY,
90     QP_KEY_TAG_PRECISION,
91     QP_KEY_TAG_TIME,
92 
93     /* Add new values here if needed, remember to update relevant code in qpTestLog.c and change format revision */
94 
95     QP_KEY_TAG_LAST /* Do not remove */
96 } qpKeyValueTag;
97 
98 /*--------------------------------------------------------------------*//*!
99  * \brief Sample value tag for giving hints for analysis
100  *//*--------------------------------------------------------------------*/
101 typedef enum qpSampleValueTag_e
102 {
103     QP_SAMPLE_VALUE_TAG_PREDICTOR = 0, /*!< Predictor for sample, such as number of operations.    */
104     QP_SAMPLE_VALUE_TAG_RESPONSE,      /*!< Response, i.e. measured value, such as render time.    */
105 
106     /* Add new values here if needed, remember to update relevant code in qpTestLog.c and change format revision */
107 
108     QP_SAMPLE_VALUE_TAG_LAST /* Do not remove */
109 } qpSampleValueTag;
110 
111 /* Image compression type. */
112 typedef enum qpImageCompressionMode_e
113 {
114     QP_IMAGE_COMPRESSION_MODE_NONE = 0, /*!< Do not compress images.                    */
115     QP_IMAGE_COMPRESSION_MODE_PNG,      /*!< Compress images using lossless libpng.        */
116     QP_IMAGE_COMPRESSION_MODE_BEST,     /*!< Choose the best image compression mode.    */
117 
118     QP_IMAGE_COMPRESSION_MODE_LAST
119 } qpImageCompressionMode;
120 
121 /*--------------------------------------------------------------------*//*!
122  * \brief Image formats.
123  *
124  * Pixels are handled as a byte stream, i.e., endianess does not
125  * affect component ordering.
126  *//*--------------------------------------------------------------------*/
127 typedef enum qpImageFormat_e
128 {
129     QP_IMAGE_FORMAT_RGB888 = 0,
130     QP_IMAGE_FORMAT_RGBA8888,
131 
132     QP_IMAGE_FORMAT_LAST
133 } qpImageFormat;
134 
135 /* Test log flags. */
136 typedef enum qpTestLogFlag_e
137 {
138     QP_TEST_LOG_EXCLUDE_IMAGES = (1 << 0) /*!< Do not log images. This reduces log size considerably.            */
139     ,
140     QP_TEST_LOG_EXCLUDE_SHADER_SOURCES =
141         (1 << 1) /*!< Do not log shader sources. Helps to reduce log size further.    */
142     ,
143     QP_TEST_LOG_NO_FLUSH = (1 << 2) /*!< Do not do a fflush after writing the log.                        */
144     ,
145     QP_TEST_LOG_EXCLUDE_EMPTY_LOGINFO = (1 << 3) /*!< Do not log empty shader compile or link loginfo.                */
146     ,
147     QP_TEST_LOG_NO_INITIAL_OUTPUT = (1 << 4) /*!< Do not push data to cout when initializing log.                */
148     ,
149     QP_TEST_LOG_COMPACT = (1 << 5) /*!< Only write test case status.                                    */
150 } qpTestLogFlag;
151 
152 /* Shader type. */
153 typedef enum qpShaderType_e
154 {
155     QP_SHADER_TYPE_VERTEX = 0,
156     QP_SHADER_TYPE_FRAGMENT,
157     QP_SHADER_TYPE_GEOMETRY,
158     QP_SHADER_TYPE_TESS_CONTROL,
159     QP_SHADER_TYPE_TESS_EVALUATION,
160     QP_SHADER_TYPE_COMPUTE,
161     QP_SHADER_TYPE_RAYGEN,
162     QP_SHADER_TYPE_ANY_HIT,
163     QP_SHADER_TYPE_CLOSEST_HIT,
164     QP_SHADER_TYPE_MISS,
165     QP_SHADER_TYPE_INTERSECTION,
166     QP_SHADER_TYPE_CALLABLE,
167     QP_SHADER_TYPE_TASK,
168     QP_SHADER_TYPE_MESH,
169 
170     QP_SHADER_TYPE_LAST
171 } qpShaderType;
172 
173 DE_BEGIN_EXTERN_C
174 
175 /* \todo [2013-04-13 pyry] Clean up & document. Do we actually want this? */
176 typedef struct qpEglConfigInfo_s
177 {
178     int bufferSize;
179     int redSize;
180     int greenSize;
181     int blueSize;
182     int luminanceSize;
183     int alphaSize;
184     int alphaMaskSize;
185     bool bindToTextureRGB;
186     bool bindToTextureRGBA;
187     const char *colorBufferType;
188     const char *configCaveat;
189     int configID;
190     const char *conformant;
191     int depthSize;
192     int level;
193     int maxPBufferWidth;
194     int maxPBufferHeight;
195     int maxPBufferPixels;
196     int maxSwapInterval;
197     int minSwapInterval;
198     bool nativeRenderable;
199     const char *renderableType;
200     int sampleBuffers;
201     int samples;
202     int stencilSize;
203     const char *surfaceTypes;
204     const char *transparentType;
205     int transparentRedValue;
206     int transparentGreenValue;
207     int transparentBlueValue;
208     bool recordableAndroid;
209 } qpEglConfigInfo;
210 
211 qpTestLog *qpTestLog_createFileLog(const char *fileName, uint32_t flags);
212 bool qpTestLog_beginSession(qpTestLog *log, const char *additionalSessionInfo);
213 void qpTestLog_destroy(qpTestLog *log);
214 bool qpTestLog_isCompact(qpTestLog *log);
215 
216 bool qpTestLog_startCase(qpTestLog *log, const char *testCasePath, qpTestCaseType testCaseType);
217 bool qpTestLog_endCase(qpTestLog *log, qpTestResult result, const char *description);
218 
219 bool qpTestLog_startTestsCasesTime(qpTestLog *log);
220 bool qpTestLog_endTestsCasesTime(qpTestLog *log);
221 
222 bool qpTestLog_terminateCase(qpTestLog *log, qpTestResult result);
223 
224 bool qpTestLog_startSection(qpTestLog *log, const char *name, const char *description);
225 bool qpTestLog_endSection(qpTestLog *log);
226 bool qpTestLog_writeText(qpTestLog *log, const char *name, const char *description, qpKeyValueTag tag,
227                          const char *value);
228 bool qpTestLog_writeInteger(qpTestLog *log, const char *name, const char *description, const char *unit,
229                             qpKeyValueTag tag, int64_t value);
230 bool qpTestLog_writeFloat(qpTestLog *log, const char *name, const char *description, const char *unit,
231                           qpKeyValueTag tag, float value);
232 
233 bool qpTestLog_startImageSet(qpTestLog *log, const char *name, const char *description);
234 bool qpTestLog_endImageSet(qpTestLog *log);
235 bool qpTestLog_writeImage(qpTestLog *log, const char *name, const char *description,
236                           qpImageCompressionMode compressionMode, qpImageFormat format, int width, int height,
237                           int stride, const void *data);
238 
239 bool qpTestLog_startEglConfigSet(qpTestLog *log, const char *key, const char *description);
240 bool qpTestLog_writeEglConfig(qpTestLog *log, const qpEglConfigInfo *config);
241 bool qpTestLog_endEglConfigSet(qpTestLog *log);
242 
243 /* \todo [2013-08-26 pyry] Unify ShaderProgram & KernelSource & CompileInfo. */
244 
245 bool qpTestLog_startShaderProgram(qpTestLog *log, bool linkOk, const char *linkInfoLog);
246 bool qpTestLog_endShaderProgram(qpTestLog *log);
247 bool qpTestLog_writeShader(qpTestLog *log, qpShaderType type, const char *source, bool compileOk, const char *infoLog);
248 
249 bool qpTestLog_writeKernelSource(qpTestLog *log, const char *source);
250 bool qpTestLog_writeSpirVAssemblySource(qpTestLog *log, const char *source);
251 bool qpTestLog_writeCompileInfo(qpTestLog *log, const char *name, const char *description, bool compileOk,
252                                 const char *infoLog);
253 
254 bool qpTestLog_startSampleList(qpTestLog *log, const char *name, const char *description);
255 bool qpTestLog_startSampleInfo(qpTestLog *log);
256 bool qpTestLog_writeValueInfo(qpTestLog *log, const char *name, const char *description, const char *unit,
257                               qpSampleValueTag tag);
258 bool qpTestLog_endSampleInfo(qpTestLog *log);
259 bool qpTestLog_startSample(qpTestLog *log);
260 bool qpTestLog_writeValueFloat(qpTestLog *log, double value);
261 bool qpTestLog_writeValueInteger(qpTestLog *log, int64_t value);
262 bool qpTestLog_endSample(qpTestLog *log);
263 bool qpTestLog_endSampleList(qpTestLog *log);
264 
265 bool qpTestLog_writeRaw(qpTestLog *log, const char *rawContents);
266 
267 uint32_t qpTestLog_getLogFlags(const qpTestLog *log);
268 
269 const char *qpGetTestResultName(qpTestResult result);
270 
271 DE_END_EXTERN_C
272 
273 /*! \} */
274 
275 #endif /* _QPTESTLOG_H */
276