1 #ifndef _XETESTCASERESULT_HPP
2 #define _XETESTCASERESULT_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 case result models.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "xeDefs.hpp"
27 #include "xeTestCase.hpp"
28 
29 #include <string>
30 #include <vector>
31 #include <ostream>
32 
33 namespace xe
34 {
35 
36 enum TestStatusCode
37 {
38 	TESTSTATUSCODE_PASS,					//!< Test case passed.
39 	TESTSTATUSCODE_FAIL,					//!< Test case failed (not passed).
40 	TESTSTATUSCODE_QUALITY_WARNING,			//!< Result within specification, but suspicious quality wise
41 	TESTSTATUSCODE_COMPATIBILITY_WARNING,	//!< Result within specification, but likely to cause fragmentation
42 	TESTSTATUSCODE_PENDING,					//!< Not yet started.
43 	TESTSTATUSCODE_RUNNING,					//!< Currently running (not stored in database).
44 	TESTSTATUSCODE_NOT_SUPPORTED,			//!< Some feature was not supported in the implementation.
45 	TESTSTATUSCODE_RESOURCE_ERROR,			//!< A resource error has occurred.
46 	TESTSTATUSCODE_INTERNAL_ERROR,			//!< An internal error has occurred.
47 	TESTSTATUSCODE_CANCELED,				//!< User canceled the execution
48 	TESTSTATUSCODE_TIMEOUT,					//!< Test was killed because of watch dog timeout.
49 	TESTSTATUSCODE_CRASH,					//!< Test executable crashed before finishing the test.
50 	TESTSTATUSCODE_DISABLED,				//!< Test case disabled (for current target)
51 	TESTSTATUSCODE_TERMINATED,				//!< Terminated for other reason.
52 
53 	TESTSTATUSCODE_LAST
54 };
55 
56 const char* getTestStatusCodeName (TestStatusCode statusCode);
57 
58 namespace ri
59 {
60 
61 class Item;
62 class Result;
63 class Text;
64 class Number;
65 class Image;
66 class ImageSet;
67 class VertexShader;
68 class FragmentShader;
69 class ShaderProgram;
70 class ShaderSource;
71 class InfoLog;
72 class EglConfig;
73 class EglConfigSet;
74 class Section;
75 class KernelSource;
76 class CompileInfo;
77 class SampleList;
78 class SampleInfo;
79 class ValueInfo;
80 class Sample;
81 class SampleValue;
82 
83 // \todo [2014-02-28 pyry] Make List<T> for items that have only specific subitems.
84 
85 class List
86 {
87 public:
88 							List			(void);
89 							~List			(void);
90 
getNumItems(void) const91 	int						getNumItems		(void) const	{ return (int)m_items.size();	}
getItem(int ndx) const92 	const Item&				getItem			(int ndx) const	{ return *m_items[ndx];			}
getItem(int ndx)93 	Item&					getItem			(int ndx)		{ return *m_items[ndx];			}
94 
95 	template <typename T>
96 	T*						allocItem		(void);
97 
98 private:
99 	std::vector<Item*>		m_items;
100 };
101 
102 template <typename T>
allocItem(void)103 T* List::allocItem (void)
104 {
105 	m_items.reserve(m_items.size()+1);
106 	T* item = new T();
107 	m_items.push_back(static_cast<ri::Item*>(item));
108 	return item;
109 }
110 
111 } // ri
112 
113 class TestCaseResultHeader
114 {
115 public:
TestCaseResultHeader(void)116 						TestCaseResultHeader	(void) : caseType(TESTCASETYPE_LAST), statusCode(TESTSTATUSCODE_LAST) {}
117 
118 	std::string			casePath;				//!< Full test case path.
119 	TestCaseType		caseType;				//!< Test case type.
120 	TestStatusCode		statusCode;				//!< Test status code.
121 	std::string			statusDetails;			//!< Status description.
122 };
123 
124 class TestCaseResult : public TestCaseResultHeader
125 {
126 public:
127 	ri::List			resultItems;			//!< Test log items.
128 };
129 
130 // Result items.
131 namespace ri
132 {
133 
134 // Result item type.
135 enum Type
136 {
137 	TYPE_RESULT = 0,
138 	TYPE_TEXT,
139 	TYPE_NUMBER,
140 	TYPE_IMAGE,
141 	TYPE_IMAGESET,
142 	TYPE_SHADER,
143 	TYPE_SHADERPROGRAM,
144 	TYPE_SHADERSOURCE,
145 	TYPE_SPIRVSOURCE,
146 	TYPE_INFOLOG,
147 	TYPE_EGLCONFIG,
148 	TYPE_EGLCONFIGSET,
149 	TYPE_SECTION,
150 	TYPE_KERNELSOURCE,
151 	TYPE_COMPILEINFO,
152 	TYPE_SAMPLELIST,
153 	TYPE_SAMPLEINFO,
154 	TYPE_VALUEINFO,
155 	TYPE_SAMPLE,
156 	TYPE_SAMPLEVALUE,
157 
158 	TYPE_LAST
159 };
160 
161 class NumericValue
162 {
163 public:
164 	enum Type
165 	{
166 		NUMVALTYPE_EMPTY = 0,
167 		NUMVALTYPE_INT64,
168 		NUMVALTYPE_FLOAT64,
169 
170 		NUMVALTYPE_LAST
171 	};
172 
NumericValue(void)173 					NumericValue	(void)			: m_type(NUMVALTYPE_EMPTY)		{}
NumericValue(deInt64 value)174 					NumericValue	(deInt64 value)	: m_type(NUMVALTYPE_INT64)		{ m_value.int64 = value;	}
NumericValue(double value)175 					NumericValue	(double value)	: m_type(NUMVALTYPE_FLOAT64)	{ m_value.float64 = value;	}
176 
getType(void) const177 	Type			getType			(void) const	{ return m_type; }
getInt64(void) const178 	deInt64			getInt64		(void) const	{ DE_ASSERT(getType() == NUMVALTYPE_INT64);		return m_value.int64;	}
getFloat64(void) const179 	double			getFloat64		(void) const	{ DE_ASSERT(getType() == NUMVALTYPE_FLOAT64);	return m_value.float64;	}
180 
181 private:
182 	Type			m_type;
183 	union
184 	{
185 		deInt64		int64;
186 		double		float64;
187 	} m_value;
188 };
189 
190 std::ostream& operator<< (std::ostream& str, const NumericValue& value);
191 
192 class Item
193 {
194 public:
195 
~Item(void)196 	virtual			~Item				(void) {}
197 
getType(void) const198 	Type			getType				(void) const { return m_type; }
199 
200 protected:
Item(Type type)201 					Item				(Type type) : m_type(type) {}
202 
203 private:
204 					Item				(const Item& other);
205 	Item&			operator=			(const Item& other);
206 
207 	Type			m_type;
208 };
209 
210 class Result : public Item
211 {
212 public:
Result(void)213 						Result			(void) : Item(TYPE_RESULT), statusCode(TESTSTATUSCODE_LAST) {}
~Result(void)214 						~Result			(void) {}
215 
216 	TestStatusCode		statusCode;
217 	std::string			details;
218 };
219 
220 class Text : public Item
221 {
222 public:
Text(void)223 						Text			(void) : Item(TYPE_TEXT) {}
~Text(void)224 						~Text			(void) {}
225 
226 	std::string			text;
227 };
228 
229 class Number : public Item
230 {
231 public:
Number(void)232 						Number			(void) : Item(TYPE_NUMBER) {}
~Number(void)233 						~Number			(void) {}
234 
235 	std::string			name;
236 	std::string			description;
237 	std::string			unit;
238 	std::string			tag;
239 	NumericValue		value;
240 };
241 
242 class Image : public Item
243 {
244 public:
245 	enum Format
246 	{
247 		FORMAT_RGB888,
248 		FORMAT_RGBA8888,
249 
250 		FORMAT_LAST
251 	};
252 
253 	enum Compression
254 	{
255 		COMPRESSION_NONE = 0,
256 		COMPRESSION_PNG,
257 
258 		COMPRESSION_LAST
259 	};
260 
Image(void)261 							Image		(void) : Item(TYPE_IMAGE), width(0), height(0), format(FORMAT_LAST), compression(COMPRESSION_LAST) {}
~Image(void)262 							~Image		(void) {}
263 
264 	std::string				name;
265 	std::string				description;
266 	int						width;
267 	int						height;
268 	Format					format;
269 	Compression				compression;
270 	std::vector<deUint8>	data;
271 };
272 
273 class ImageSet : public Item
274 {
275 public:
ImageSet(void)276 						ImageSet		(void) : Item(TYPE_IMAGESET) {}
~ImageSet(void)277 						~ImageSet		(void) {}
278 
279 	std::string			name;
280 	std::string			description;
281 	List				images;
282 };
283 
284 class ShaderSource : public Item
285 {
286 public:
ShaderSource(void)287 						ShaderSource		(void) : Item(TYPE_SHADERSOURCE) {}
~ShaderSource(void)288 						~ShaderSource		(void) {}
289 
290 	std::string			source;
291 };
292 
293 class SpirVSource : public Item
294 {
295 public:
SpirVSource(void)296 						SpirVSource			(void) : Item(TYPE_SPIRVSOURCE) {}
~SpirVSource(void)297 						~SpirVSource		(void) {}
298 
299 	std::string			source;
300 };
301 
302 class InfoLog : public Item
303 {
304 public:
InfoLog(void)305 						InfoLog				(void) : Item(TYPE_INFOLOG) {}
~InfoLog(void)306 						~InfoLog			(void) {}
307 
308 	std::string			log;
309 };
310 
311 class Shader : public Item
312 {
313 public:
314 	enum ShaderType
315 	{
316 		SHADERTYPE_VERTEX = 0,
317 		SHADERTYPE_FRAGMENT,
318 		SHADERTYPE_GEOMETRY,
319 		SHADERTYPE_TESS_CONTROL,
320 		SHADERTYPE_TESS_EVALUATION,
321 		SHADERTYPE_COMPUTE,
322 		SHADERTYPE_RAYGEN,
323 		SHADERTYPE_ANY_HIT,
324 		SHADERTYPE_CLOSEST_HIT,
325 		SHADERTYPE_MISS,
326 		SHADERTYPE_INTERSECTION,
327 		SHADERTYPE_CALLABLE,
328 
329 		SHADERTYPE_LAST
330 	};
331 
Shader(void)332 						Shader				(void) : Item(TYPE_SHADER), shaderType(SHADERTYPE_LAST), compileStatus(false) {}
~Shader(void)333 						~Shader				(void) {}
334 
335 	ShaderType			shaderType;
336 	bool				compileStatus;
337 	ShaderSource		source;
338 	InfoLog				infoLog;
339 };
340 
341 class ShaderProgram : public Item
342 {
343 public:
ShaderProgram(void)344 						ShaderProgram		(void) : Item(TYPE_SHADERPROGRAM), linkStatus(false) {}
~ShaderProgram(void)345 						~ShaderProgram		(void) {}
346 
347 	List				shaders;
348 	bool				linkStatus;
349 	InfoLog				linkInfoLog;
350 };
351 
352 class EglConfig : public Item
353 {
354 public:
355 						EglConfig			(void);
~EglConfig(void)356 						~EglConfig			(void) {}
357 
358 	int					bufferSize;
359 	int					redSize;
360 	int					greenSize;
361 	int					blueSize;
362 	int					luminanceSize;
363 	int					alphaSize;
364 	int					alphaMaskSize;
365 	bool				bindToTextureRGB;
366 	bool				bindToTextureRGBA;
367 	std::string			colorBufferType;
368 	std::string			configCaveat;
369 	int					configID;
370 	std::string			conformant;
371 	int					depthSize;
372 	int					level;
373 	int					maxPBufferWidth;
374 	int					maxPBufferHeight;
375 	int					maxPBufferPixels;
376 	int					maxSwapInterval;
377 	int					minSwapInterval;
378 	bool				nativeRenderable;
379 	std::string			renderableType;
380 	int					sampleBuffers;
381 	int					samples;
382 	int					stencilSize;
383 	std::string			surfaceTypes;
384 	std::string			transparentType;
385 	int					transparentRedValue;
386 	int					transparentGreenValue;
387 	int					transparentBlueValue;
388 };
389 
EglConfig(void)390 inline EglConfig::EglConfig (void)
391 	: Item					(TYPE_EGLCONFIG)
392 	, bufferSize			(0)
393 	, redSize				(0)
394 	, greenSize				(0)
395 	, blueSize				(0)
396 	, luminanceSize			(0)
397 	, alphaSize				(0)
398 	, alphaMaskSize			(0)
399 	, bindToTextureRGB		(false)
400 	, bindToTextureRGBA		(false)
401 	, configID				(0)
402 	, depthSize				(0)
403 	, level					(0)
404 	, maxPBufferWidth		(0)
405 	, maxPBufferHeight		(0)
406 	, maxPBufferPixels		(0)
407 	, maxSwapInterval		(0)
408 	, minSwapInterval		(0)
409 	, nativeRenderable		(false)
410 	, sampleBuffers			(0)
411 	, samples				(0)
412 	, stencilSize			(0)
413 	, transparentRedValue	(0)
414 	, transparentGreenValue	(0)
415 	, transparentBlueValue	(0)
416 {
417 }
418 
419 class EglConfigSet : public Item
420 {
421 public:
EglConfigSet(void)422 						EglConfigSet		(void) : Item(TYPE_EGLCONFIGSET) {}
~EglConfigSet(void)423 						~EglConfigSet		(void) {}
424 
425 	std::string			name;
426 	std::string			description;
427 	List				configs;
428 };
429 
430 class Section : public Item
431 {
432 public:
Section(void)433 						Section			(void) : Item(TYPE_SECTION) {}
~Section(void)434 						~Section		(void) {}
435 
436 	std::string			name;
437 	std::string			description;
438 	List				items;
439 };
440 
441 class KernelSource : public Item
442 {
443 public:
KernelSource(void)444 						KernelSource	(void) : Item(TYPE_KERNELSOURCE) {}
~KernelSource(void)445 						~KernelSource	(void) {}
446 
447 	std::string			source;
448 };
449 
450 class CompileInfo : public Item
451 {
452 public:
CompileInfo(void)453 						CompileInfo		(void) : Item(TYPE_COMPILEINFO), compileStatus(false) {}
~CompileInfo(void)454 						~CompileInfo	(void) {}
455 
456 	std::string			name;
457 	std::string			description;
458 	bool				compileStatus;
459 	InfoLog				infoLog;
460 };
461 
462 class ValueInfo : public Item
463 {
464 public:
465 	enum ValueTag
466 	{
467 		VALUETAG_PREDICTOR,
468 		VALUETAG_RESPONSE,
469 
470 		VALUETAG_LAST
471 	};
472 
ValueInfo(void)473 						ValueInfo		(void) : Item(TYPE_VALUEINFO), tag(VALUETAG_LAST) {}
~ValueInfo(void)474 						~ValueInfo		(void) {}
475 
476 	std::string			name;
477 	std::string			description;
478 	std::string			unit;
479 	ValueTag			tag;
480 };
481 
482 class SampleInfo : public Item
483 {
484 public:
SampleInfo(void)485 						SampleInfo		(void) : Item(TYPE_SAMPLEINFO) {}
~SampleInfo(void)486 						~SampleInfo		(void) {}
487 
488 	List				valueInfos;
489 };
490 
491 class SampleValue : public Item
492 {
493 public:
SampleValue(void)494 						SampleValue		(void) : Item(TYPE_SAMPLEVALUE) {}
~SampleValue(void)495 						~SampleValue	(void) {}
496 
497 	NumericValue		value;
498 };
499 
500 class Sample : public Item
501 {
502 public:
Sample(void)503 						Sample			(void) : Item(TYPE_SAMPLE) {}
~Sample(void)504 						~Sample			(void) {}
505 
506 	List				values;
507 };
508 
509 class SampleList : public Item
510 {
511 public:
SampleList(void)512 						SampleList		(void) : Item(TYPE_SAMPLELIST) {}
~SampleList(void)513 						~SampleList		(void) {}
514 
515 	std::string			name;
516 	std::string			description;
517 	SampleInfo			sampleInfo;
518 	List				samples;
519 };
520 
521 } // ri
522 } // xe
523 
524 #endif // _XETESTCASERESULT_HPP
525