1 /*-------------------------------------------------------------------------
2  * drawElements Internal Test Module
3  * ---------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief delibs self-tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "ditDelibsTests.hpp"
25 #include "tcuTestLog.hpp"
26 
27 // depool
28 #include "dePoolArray.h"
29 #include "dePoolHeap.h"
30 #include "dePoolHash.h"
31 #include "dePoolSet.h"
32 #include "dePoolHashSet.h"
33 #include "dePoolHashArray.h"
34 #include "dePoolMultiSet.h"
35 
36 // dethread
37 #include "deThreadTest.h"
38 #include "deThread.h"
39 
40 // deutil
41 #include "deTimerTest.h"
42 #include "deCommandLine.h"
43 
44 // debase
45 #include "deInt32.h"
46 #include "deMath.h"
47 
48 // decpp
49 #include "deBlockBuffer.hpp"
50 #include "deFilePath.hpp"
51 #include "dePoolArray.hpp"
52 #include "deRingBuffer.hpp"
53 #include "deSharedPtr.hpp"
54 #include "deThreadSafeRingBuffer.hpp"
55 #include "deUniquePtr.hpp"
56 #include "deRandom.hpp"
57 #include "deCommandLine.hpp"
58 #include "deArrayBuffer.hpp"
59 #include "deStringUtil.hpp"
60 #include "deSpinBarrier.hpp"
61 #include "deSTLUtil.hpp"
62 
63 namespace dit
64 {
65 
66 using tcu::TestLog;
67 
68 class DepoolTests : public tcu::TestCaseGroup
69 {
70 public:
DepoolTests(tcu::TestContext & testCtx)71 	DepoolTests (tcu::TestContext& testCtx)
72 		: tcu::TestCaseGroup(testCtx, "depool", "depool self-tests")
73 	{
74 	}
75 
init(void)76 	void init (void)
77 	{
78 		addChild(new SelfCheckCase(m_testCtx, "array",		"dePoolArray_selfTest()",		dePoolArray_selfTest));
79 		addChild(new SelfCheckCase(m_testCtx, "heap",		"dePoolHeap_selfTest()",		dePoolHeap_selfTest));
80 		addChild(new SelfCheckCase(m_testCtx, "hash",		"dePoolHash_selfTest()",		dePoolHash_selfTest));
81 		addChild(new SelfCheckCase(m_testCtx, "set",		"dePoolSet_selfTest()",			dePoolSet_selfTest));
82 		addChild(new SelfCheckCase(m_testCtx, "hash_set",	"dePoolHashSet_selfTest()",		dePoolHashSet_selfTest));
83 		addChild(new SelfCheckCase(m_testCtx, "hash_array",	"dePoolHashArray_selfTest()",	dePoolHashArray_selfTest));
84 		addChild(new SelfCheckCase(m_testCtx, "multi_set",	"dePoolMultiSet_selfTest()",	dePoolMultiSet_selfTest));
85 	}
86 };
87 
88 extern "C"
89 {
90 typedef deUint32	(*GetUint32Func)	(void);
91 }
92 
93 class GetUint32Case : public tcu::TestCase
94 {
95 public:
GetUint32Case(tcu::TestContext & testCtx,const char * name,const char * description,GetUint32Func func)96 	GetUint32Case (tcu::TestContext& testCtx, const char* name, const char* description, GetUint32Func func)
97 		: tcu::TestCase	(testCtx, name, description)
98 		, m_func		(func)
99 	{
100 	}
101 
iterate(void)102 	IterateResult iterate (void)
103 	{
104 		m_testCtx.getLog() << TestLog::Message << getDescription() << " returned " << m_func() << TestLog::EndMessage;
105 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
106 		return STOP;
107 	}
108 
109 private:
110 	GetUint32Func	m_func;
111 };
112 
113 class DethreadTests : public tcu::TestCaseGroup
114 {
115 public:
DethreadTests(tcu::TestContext & testCtx)116 	DethreadTests (tcu::TestContext& testCtx)
117 		: tcu::TestCaseGroup(testCtx, "dethread", "dethread self-tests")
118 	{
119 	}
120 
init(void)121 	void init (void)
122 	{
123 		addChild(new SelfCheckCase(m_testCtx, "thread",						"deThread_selfTest()",				deThread_selfTest));
124 		addChild(new SelfCheckCase(m_testCtx, "mutex",						"deMutex_selfTest()",				deMutex_selfTest));
125 		addChild(new SelfCheckCase(m_testCtx, "semaphore",					"deSemaphore_selfTest()",			deSemaphore_selfTest));
126 		addChild(new SelfCheckCase(m_testCtx, "atomic",						"deAtomic_selfTest()",				deAtomic_selfTest));
127 		addChild(new SelfCheckCase(m_testCtx, "singleton",					"deSingleton_selfTest()",			deSingleton_selfTest));
128 		addChild(new GetUint32Case(m_testCtx, "total_physical_cores",		"deGetNumTotalPhysicalCores()",		deGetNumTotalPhysicalCores));
129 		addChild(new GetUint32Case(m_testCtx, "total_logical_cores",		"deGetNumTotalLogicalCores()",		deGetNumTotalLogicalCores));
130 		addChild(new GetUint32Case(m_testCtx, "available_logical_cores",	"deGetNumAvailableLogicalCores()",	deGetNumAvailableLogicalCores));
131 	}
132 };
133 
134 class DeutilTests : public tcu::TestCaseGroup
135 {
136 public:
DeutilTests(tcu::TestContext & testCtx)137 	DeutilTests (tcu::TestContext& testCtx)
138 		: tcu::TestCaseGroup(testCtx, "deutil", "deutil self-tests")
139 	{
140 	}
141 
init(void)142 	void init (void)
143 	{
144 		addChild(new SelfCheckCase(m_testCtx, "timer",			"deTimer_selfTest()",		deTimer_selfTest));
145 		addChild(new SelfCheckCase(m_testCtx, "command_line",	"deCommandLine_selfTest()",	deCommandLine_selfTest));
146 	}
147 };
148 
149 class DebaseTests : public tcu::TestCaseGroup
150 {
151 public:
DebaseTests(tcu::TestContext & testCtx)152 	DebaseTests (tcu::TestContext& testCtx)
153 		: tcu::TestCaseGroup(testCtx, "debase", "debase self-tests")
154 	{
155 	}
156 
init(void)157 	void init (void)
158 	{
159 		addChild(new SelfCheckCase(m_testCtx, "int32",	"deInt32_selfTest()",	deInt32_selfTest));
160 		addChild(new SelfCheckCase(m_testCtx, "math",	"deMath_selfTest()",	deMath_selfTest));
161 	}
162 };
163 
164 class DecppTests : public tcu::TestCaseGroup
165 {
166 public:
DecppTests(tcu::TestContext & testCtx)167 	DecppTests (tcu::TestContext& testCtx)
168 		: tcu::TestCaseGroup(testCtx, "decpp", "decpp self-tests")
169 	{
170 	}
171 
init(void)172 	void init (void)
173 	{
174 		addChild(new SelfCheckCase(m_testCtx, "block_buffer",				"de::BlockBuffer_selfTest()",			de::BlockBuffer_selfTest));
175 		addChild(new SelfCheckCase(m_testCtx, "file_path",					"de::FilePath_selfTest()",				de::FilePath_selfTest));
176 		addChild(new SelfCheckCase(m_testCtx, "pool_array",					"de::PoolArray_selfTest()",				de::PoolArray_selfTest));
177 		addChild(new SelfCheckCase(m_testCtx, "ring_buffer",				"de::RingBuffer_selfTest()",			de::RingBuffer_selfTest));
178 		addChild(new SelfCheckCase(m_testCtx, "shared_ptr",					"de::SharedPtr_selfTest()",				de::SharedPtr_selfTest));
179 		addChild(new SelfCheckCase(m_testCtx, "thread_safe_ring_buffer",	"de::ThreadSafeRingBuffer_selfTest()",	de::ThreadSafeRingBuffer_selfTest));
180 		addChild(new SelfCheckCase(m_testCtx, "unique_ptr",					"de::UniquePtr_selfTest()",				de::UniquePtr_selfTest));
181 		addChild(new SelfCheckCase(m_testCtx, "random",						"de::Random_selfTest()",				de::Random_selfTest));
182 		addChild(new SelfCheckCase(m_testCtx, "commandline",				"de::cmdline::selfTest()",				de::cmdline::selfTest));
183 		addChild(new SelfCheckCase(m_testCtx, "array_buffer",				"de::ArrayBuffer_selfTest()",			de::ArrayBuffer_selfTest));
184 		addChild(new SelfCheckCase(m_testCtx, "string_util",				"de::StringUtil_selfTest()",			de::StringUtil_selfTest));
185 		addChild(new SelfCheckCase(m_testCtx, "spin_barrier",				"de::SpinBarrier_selfTest()",			de::SpinBarrier_selfTest));
186 		addChild(new SelfCheckCase(m_testCtx, "stl_util",					"de::STLUtil_selfTest()",				de::STLUtil_selfTest));
187 	}
188 };
189 
DelibsTests(tcu::TestContext & testCtx)190 DelibsTests::DelibsTests (tcu::TestContext& testCtx)
191 	: tcu::TestCaseGroup(testCtx, "delibs", "delibs Tests")
192 {
193 }
194 
~DelibsTests(void)195 DelibsTests::~DelibsTests (void)
196 {
197 }
198 
init(void)199 void DelibsTests::init (void)
200 {
201 	addChild(new DepoolTests	(m_testCtx));
202 	addChild(new DethreadTests	(m_testCtx));
203 	addChild(new DeutilTests	(m_testCtx));
204 	addChild(new DebaseTests	(m_testCtx));
205 	addChild(new DecppTests		(m_testCtx));
206 }
207 
208 } // dit
209