00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00027
00028 #include "../include/TestThread.h"
00029 #include "../../include/PCMFileSystemManager.h"
00030
00031 namespace ParCompMarkTest
00032 {
00033
00034 void TestThread::setUp()
00035 {
00036 std::string currentLogFile = "logs/TestThread.log";
00037
00038 if(Logger::getInstance() && Logger::getInstance()->getLogFileName() != currentLogFile)
00039 Logger::destroyInstance();
00040
00041 if(!FileSystemManager::getInstance())
00042 {
00043 FileSystemManager::createInstance();
00044 FileSystemManager::getInstance()->setAppDirectory("./");
00045 FileSystemManager::getInstance()->initialize();
00046 }
00047
00048 if(!Logger::getInstance())
00049 {
00050 Logger::createInstance();
00051 Logger::getInstance()->setLogFileName(currentLogFile);
00052 Logger::getInstance()->initialize();
00053 }
00054 }
00055
00056
00057
00058 void TestThread::tearDown()
00059 {
00060 }
00061
00062
00063
00064
00065
00066
00067
00068 void TestThread::test_constructor_cstd__string()
00069 {
00070
00071
00072
00073
00074
00075
00076
00077 Thread *t = 0;
00078
00079 CPPUNIT_ASSERT_NO_THROW(t = new Thread("test_constructor_std__string"));
00080 delete t;
00081 }
00082
00083
00084
00085 void TestThread::test_destructor()
00086 {
00087
00088
00089 Thread *t;
00090
00091 t = new Thread("test_destructor");
00092 t->initThread(1, 0, true, true);
00093 sleep(2);
00094 CPPUNIT_ASSERT_NO_THROW(delete t);
00095
00096 t = new Thread("test_destructor");
00097 t->initThread(10, 0, true, true);
00098 CPPUNIT_ASSERT_NO_THROW(delete t);
00099
00100 t = new Thread("test_destructor");
00101 t->initThread(10, 0, true, false);
00102 CPPUNIT_ASSERT_NO_THROW(delete t);
00103
00104 }
00105
00106
00107
00108
00109
00110
00111
00112 void TestThread::test_yield()
00113 {
00114
00115
00116
00117
00118
00119
00120
00121 CPPUNIT_ASSERT_NO_THROW(Thread::yield());
00122 }
00123
00124
00125
00126 void TestThread::test_getUSTime()
00127 {
00128
00129
00130
00131
00132
00133
00134
00135
00136 ParCompMark::Real time1;
00137 CPPUNIT_ASSERT_NO_THROW(time1 = Thread::getUSTime());
00138 CPPUNIT_ASSERT(time1 > 0.0);
00139
00140 usleep(10 * 1000);
00141
00142
00143 ParCompMark::Real time2;
00144 CPPUNIT_ASSERT_NO_THROW(time2 = Thread::getUSTime());
00145 CPPUNIT_ASSERT(time2 >= time1);
00146 }
00147
00148
00149
00150 void TestThread::test_entryPoint_void_p()
00151 {
00152
00153
00154
00155
00156
00157
00158
00159
00160 }
00161
00162
00163
00164
00165
00166
00167
00168 void TestThread::test_initThread_cu32_cu32_cbool_cbool()
00169 {
00170
00171
00172
00173
00174
00175
00176
00177 Thread *t = new Thread("test_initThread_u32_u32");
00178
00179 CPPUNIT_ASSERT_NO_THROW(t->initThread());
00180 CPPUNIT_ASSERT_THROW(t->initThread(0, 100, true, true), ParCompMark::Exception);
00181 CPPUNIT_ASSERT_NO_THROW(t->initThread(10, 100, true, true));
00182 CPPUNIT_ASSERT_NO_THROW(t->initThread(10, 100, true, false));
00183 CPPUNIT_ASSERT_NO_THROW(t->initThread(10, 100, false, false));
00184 CPPUNIT_ASSERT_THROW(t->initThread(10, 100, false, true), ParCompMark::Exception);
00185 CPPUNIT_ASSERT(t->mIterationNumber == 10);
00186 CPPUNIT_ASSERT(t->mExpectedFPS == 100);
00187 delete t;
00188 }
00189
00190
00191
00192 void TestThread::test_threadInitialize()
00193 {
00194
00195
00196
00197
00198
00199
00200
00201 CPPUNIT_FAIL("Implement this test!");
00202 }
00203
00204
00205
00206 void TestThread::test_threadFinalize()
00207 {
00208
00209
00210
00211
00212
00213
00214
00215 CPPUNIT_FAIL("Implement this test!");
00216 }
00217
00218
00219
00220 void TestThread::test_startThread()
00221 {
00222
00223
00224
00225
00226
00227
00228
00229
00230 Thread *t = new Thread("test_startThread 1");
00231
00232 t->initThread(100, 0);
00233 CPPUNIT_ASSERT_NO_THROW(t->startThread());
00234 CPPUNIT_ASSERT_NO_THROW(delete t);
00235
00236
00237 t = new Thread("test_startThread 2");
00238 t->initThread(1, 0);
00239 CPPUNIT_ASSERT_NO_THROW(t->startThread());
00240 usleep(500 * 1000);
00241 CPPUNIT_ASSERT_NO_THROW(delete t);
00242
00243
00244 t = new Thread("test_startThread 3");
00245 t->initThread(10, 0, true, true);
00246 t->startThread();
00247 CPPUNIT_ASSERT_NO_THROW(delete t);
00248
00249 t = new Thread("test_startThread 3");
00250 t->initThread(10, 0, true, false);
00251 t->startThread();
00252 CPPUNIT_ASSERT_NO_THROW(delete t);
00253
00254 }
00255
00256
00257
00258 void TestThread::test_joinThread()
00259 {
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 Thread *t;
00270
00271 t = new Thread("test_joinThread");
00272 t->initThread(10, 0, true, false);
00273 t->startThread();
00274 CPPUNIT_ASSERT_NO_THROW(delete t);
00275
00276 t = new Thread("test_joinThread");
00277 t->initThread(10, 0, true, false);
00278 t->startThread();
00279 t->joinThread();
00280 CPPUNIT_ASSERT_NO_THROW(delete t);
00281
00282
00283 t = new Thread("test_joinThread");
00284 t->initThread(1, 0, true, false);
00285 t->startThread();
00286 sleep(2);
00287 CPPUNIT_ASSERT_NO_THROW(t->joinThread());
00288 CPPUNIT_ASSERT_NO_THROW(delete t);
00289
00290 t = new Thread("test_joinThread");
00291 t->initThread(0, 0, true, false);
00292 t->startThread();
00293 t->stopThread();
00294 CPPUNIT_ASSERT_NO_THROW(t->joinThread());
00295 CPPUNIT_ASSERT_NO_THROW(delete t);
00296
00297 t = new Thread("test_joinThread");
00298 t->initThread(0, 0, true, false);
00299 t->startThread();
00300 t->stopThread();
00301 sleep(1);
00302 CPPUNIT_ASSERT_NO_THROW(t->joinThread());
00303 CPPUNIT_ASSERT_NO_THROW(delete t);
00304
00305 }
00306
00307
00308
00309 void TestThread::test_shutDownThread()
00310 {
00311
00312
00313
00314
00315
00316
00317
00318
00319 }
00320
00321
00322
00323 void TestThread::test_stopThread()
00324 {
00325
00326
00327
00328
00329
00330
00331
00332
00333 Thread *t = new Thread("test_stopThread");
00334
00335 t->initThread(1000, 0);
00336 CPPUNIT_ASSERT_NO_THROW(t->startThread());
00337 usleep(10 * 1000);
00338 CPPUNIT_ASSERT_NO_THROW(t->stopThread());
00339 usleep(500 * 1000);
00340 CPPUNIT_ASSERT_NO_THROW(delete t);
00341 }
00342
00343
00344
00345 void TestThread::test_go()
00346 {
00347
00348
00349
00350
00351
00352
00353
00354 CPPUNIT_FAIL("Implement this test!");
00355 }
00356
00357
00358
00359 void TestThread::test_thread()
00360 {
00361
00362
00363
00364
00365
00366
00367
00368
00369 }
00370
00371
00372
00373 void TestThread::test_iteration()
00374 {
00375
00376
00377
00378
00379
00380
00381
00382
00383 }
00384
00385
00386
00387 void TestThread::test_task()
00388 {
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399 }
00400
00401
00402
00403 void TestThread::test_wait()
00404 {
00405
00406
00407
00408
00409
00410
00411
00412 CPPUNIT_FAIL("Implement this test!");
00413 }
00414
00415
00416
00417
00419 CPPUNIT_TEST_SUITE_REGISTRATION(TestThread);
00420 }