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