Merge "Properly clean up data in buffer upload test deinit()."
[platform/upstream/VK-GL-CTS.git] / modules / internal / ditDelibsTests.cpp
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 #include "deSha1.h"
48 #include "deMemory.h"
49
50 // decpp
51 #include "deBlockBuffer.hpp"
52 #include "deFilePath.hpp"
53 #include "dePoolArray.hpp"
54 #include "deRingBuffer.hpp"
55 #include "deSharedPtr.hpp"
56 #include "deThreadSafeRingBuffer.hpp"
57 #include "deUniquePtr.hpp"
58 #include "deRandom.hpp"
59 #include "deCommandLine.hpp"
60 #include "deArrayBuffer.hpp"
61 #include "deStringUtil.hpp"
62 #include "deSpinBarrier.hpp"
63 #include "deSTLUtil.hpp"
64 #include "deAppendList.hpp"
65
66 namespace dit
67 {
68
69 using tcu::TestLog;
70
71 class DepoolTests : public tcu::TestCaseGroup
72 {
73 public:
74         DepoolTests (tcu::TestContext& testCtx)
75                 : tcu::TestCaseGroup(testCtx, "depool", "depool self-tests")
76         {
77         }
78
79         void init (void)
80         {
81                 addChild(new SelfCheckCase(m_testCtx, "array",          "dePoolArray_selfTest()",               dePoolArray_selfTest));
82                 addChild(new SelfCheckCase(m_testCtx, "heap",           "dePoolHeap_selfTest()",                dePoolHeap_selfTest));
83                 addChild(new SelfCheckCase(m_testCtx, "hash",           "dePoolHash_selfTest()",                dePoolHash_selfTest));
84                 addChild(new SelfCheckCase(m_testCtx, "set",            "dePoolSet_selfTest()",                 dePoolSet_selfTest));
85                 addChild(new SelfCheckCase(m_testCtx, "hash_set",       "dePoolHashSet_selfTest()",             dePoolHashSet_selfTest));
86                 addChild(new SelfCheckCase(m_testCtx, "hash_array",     "dePoolHashArray_selfTest()",   dePoolHashArray_selfTest));
87                 addChild(new SelfCheckCase(m_testCtx, "multi_set",      "dePoolMultiSet_selfTest()",    dePoolMultiSet_selfTest));
88         }
89 };
90
91 extern "C"
92 {
93 typedef deUint32        (*GetUint32Func)        (void);
94 }
95
96 class GetUint32Case : public tcu::TestCase
97 {
98 public:
99         GetUint32Case (tcu::TestContext& testCtx, const char* name, const char* description, GetUint32Func func)
100                 : tcu::TestCase (testCtx, name, description)
101                 , m_func                (func)
102         {
103         }
104
105         IterateResult iterate (void)
106         {
107                 m_testCtx.getLog() << TestLog::Message << getDescription() << " returned " << m_func() << TestLog::EndMessage;
108                 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
109                 return STOP;
110         }
111
112 private:
113         GetUint32Func   m_func;
114 };
115
116 class DethreadTests : public tcu::TestCaseGroup
117 {
118 public:
119         DethreadTests (tcu::TestContext& testCtx)
120                 : tcu::TestCaseGroup(testCtx, "dethread", "dethread self-tests")
121         {
122         }
123
124         void init (void)
125         {
126                 addChild(new SelfCheckCase(m_testCtx, "thread",                                         "deThread_selfTest()",                          deThread_selfTest));
127                 addChild(new SelfCheckCase(m_testCtx, "mutex",                                          "deMutex_selfTest()",                           deMutex_selfTest));
128                 addChild(new SelfCheckCase(m_testCtx, "semaphore",                                      "deSemaphore_selfTest()",                       deSemaphore_selfTest));
129                 addChild(new SelfCheckCase(m_testCtx, "atomic",                                         "deAtomic_selfTest()",                          deAtomic_selfTest));
130                 addChild(new SelfCheckCase(m_testCtx, "singleton",                                      "deSingleton_selfTest()",                       deSingleton_selfTest));
131                 addChild(new GetUint32Case(m_testCtx, "total_physical_cores",           "deGetNumTotalPhysicalCores()",         deGetNumTotalPhysicalCores));
132                 addChild(new GetUint32Case(m_testCtx, "total_logical_cores",            "deGetNumTotalLogicalCores()",          deGetNumTotalLogicalCores));
133                 addChild(new GetUint32Case(m_testCtx, "available_logical_cores",        "deGetNumAvailableLogicalCores()",      deGetNumAvailableLogicalCores));
134         }
135 };
136
137 class DeutilTests : public tcu::TestCaseGroup
138 {
139 public:
140         DeutilTests (tcu::TestContext& testCtx)
141                 : tcu::TestCaseGroup(testCtx, "deutil", "deutil self-tests")
142         {
143         }
144
145         void init (void)
146         {
147                 addChild(new SelfCheckCase(m_testCtx, "timer",                  "deTimer_selfTest()",           deTimer_selfTest));
148                 addChild(new SelfCheckCase(m_testCtx, "command_line",   "deCommandLine_selfTest()",     deCommandLine_selfTest));
149         }
150 };
151
152 class DebaseTests : public tcu::TestCaseGroup
153 {
154 public:
155         DebaseTests (tcu::TestContext& testCtx)
156                 : tcu::TestCaseGroup(testCtx, "debase", "debase self-tests")
157         {
158         }
159
160         void init (void)
161         {
162                 addChild(new SelfCheckCase(m_testCtx, "int32",  "deInt32_selfTest()",   deInt32_selfTest));
163                 addChild(new SelfCheckCase(m_testCtx, "math",   "deMath_selfTest()",    deMath_selfTest));
164                 addChild(new SelfCheckCase(m_testCtx, "sha1",   "deSha1_selfTest()",    deSha1_selfTest));
165                 addChild(new SelfCheckCase(m_testCtx, "memory", "deMemory_selfTest()",  deMemory_selfTest));
166         }
167 };
168
169 class DecppTests : public tcu::TestCaseGroup
170 {
171 public:
172         DecppTests (tcu::TestContext& testCtx)
173                 : tcu::TestCaseGroup(testCtx, "decpp", "decpp self-tests")
174         {
175         }
176
177         void init (void)
178         {
179                 addChild(new SelfCheckCase(m_testCtx, "block_buffer",                           "de::BlockBuffer_selfTest()",                   de::BlockBuffer_selfTest));
180                 addChild(new SelfCheckCase(m_testCtx, "file_path",                                      "de::FilePath_selfTest()",                              de::FilePath_selfTest));
181                 addChild(new SelfCheckCase(m_testCtx, "pool_array",                                     "de::PoolArray_selfTest()",                             de::PoolArray_selfTest));
182                 addChild(new SelfCheckCase(m_testCtx, "ring_buffer",                            "de::RingBuffer_selfTest()",                    de::RingBuffer_selfTest));
183                 addChild(new SelfCheckCase(m_testCtx, "shared_ptr",                                     "de::SharedPtr_selfTest()",                             de::SharedPtr_selfTest));
184                 addChild(new SelfCheckCase(m_testCtx, "thread_safe_ring_buffer",        "de::ThreadSafeRingBuffer_selfTest()",  de::ThreadSafeRingBuffer_selfTest));
185                 addChild(new SelfCheckCase(m_testCtx, "unique_ptr",                                     "de::UniquePtr_selfTest()",                             de::UniquePtr_selfTest));
186                 addChild(new SelfCheckCase(m_testCtx, "random",                                         "de::Random_selfTest()",                                de::Random_selfTest));
187                 addChild(new SelfCheckCase(m_testCtx, "commandline",                            "de::cmdline::selfTest()",                              de::cmdline::selfTest));
188                 addChild(new SelfCheckCase(m_testCtx, "array_buffer",                           "de::ArrayBuffer_selfTest()",                   de::ArrayBuffer_selfTest));
189                 addChild(new SelfCheckCase(m_testCtx, "string_util",                            "de::StringUtil_selfTest()",                    de::StringUtil_selfTest));
190                 addChild(new SelfCheckCase(m_testCtx, "spin_barrier",                           "de::SpinBarrier_selfTest()",                   de::SpinBarrier_selfTest));
191                 addChild(new SelfCheckCase(m_testCtx, "stl_util",                                       "de::STLUtil_selfTest()",                               de::STLUtil_selfTest));
192                 addChild(new SelfCheckCase(m_testCtx, "append_list",                            "de::AppendList_selfTest()",                    de::AppendList_selfTest));
193         }
194 };
195
196 DelibsTests::DelibsTests (tcu::TestContext& testCtx)
197         : tcu::TestCaseGroup(testCtx, "delibs", "delibs Tests")
198 {
199 }
200
201 DelibsTests::~DelibsTests (void)
202 {
203 }
204
205 void DelibsTests::init (void)
206 {
207         addChild(new DepoolTests        (m_testCtx));
208         addChild(new DethreadTests      (m_testCtx));
209         addChild(new DeutilTests        (m_testCtx));
210         addChild(new DebaseTests        (m_testCtx));
211         addChild(new DecppTests         (m_testCtx));
212 }
213
214 } // dit