Marc Slemko | 8a40a76 | 2006-07-19 17:46:50 +0000 | [diff] [blame] | 1 | #include <iostream> |
| 2 | #include <string> |
| 3 | |
| 4 | #include "ThreadFactoryTests.h" |
| 5 | #include "TimerManagerTests.h" |
Marc Slemko | d466b21 | 2006-07-20 00:04:18 +0000 | [diff] [blame] | 6 | #include "ThreadManagerTests.h" |
Marc Slemko | 8a40a76 | 2006-07-19 17:46:50 +0000 | [diff] [blame] | 7 | |
| 8 | int main(int argc, char** argv) { |
| 9 | |
| 10 | std::string arg; |
| 11 | |
| 12 | if(argc < 2) { |
| 13 | |
| 14 | arg = "all"; |
| 15 | |
| 16 | } else { |
| 17 | |
| 18 | arg = std::string(argv[1]); |
| 19 | } |
| 20 | |
| 21 | bool runAll = arg.compare("all") == 0; |
| 22 | |
| 23 | if(runAll || arg.compare("thread-factory") == 0) { |
| 24 | |
| 25 | ThreadFactoryTests threadFactoryTests; |
| 26 | |
| 27 | std::cout << "ThreadFactory tests..." << std::endl; |
| 28 | |
| 29 | std::cout << "\tThreadFactory hello-world test" << std::endl; |
| 30 | |
| 31 | assert(threadFactoryTests.helloWorldTest()); |
| 32 | |
Marc Slemko | fe5ba12e | 2006-07-20 21:16:27 +0000 | [diff] [blame] | 33 | size_t count = 1000; |
Marc Slemko | 8a40a76 | 2006-07-19 17:46:50 +0000 | [diff] [blame] | 34 | |
Marc Slemko | 03dedd9 | 2006-07-20 00:58:47 +0000 | [diff] [blame] | 35 | std::cout << "\t\tThreadFactory reap N threads test: N = " << count << std::endl; |
| 36 | |
| 37 | assert(threadFactoryTests.reapNThreads(count)); |
Marc Slemko | 8a40a76 | 2006-07-19 17:46:50 +0000 | [diff] [blame] | 38 | |
Marc Slemko | fe5ba12e | 2006-07-20 21:16:27 +0000 | [diff] [blame] | 39 | std::cout << "\t\tThreadFactory synchronous start test" << std::endl; |
Marc Slemko | 8a40a76 | 2006-07-19 17:46:50 +0000 | [diff] [blame] | 40 | |
| 41 | assert(threadFactoryTests.synchStartTest()); |
| 42 | } |
| 43 | |
| 44 | if(runAll || arg.compare("timer-manager") == 0) { |
| 45 | |
| 46 | std::cout << "TimerManager tests..." << std::endl; |
| 47 | |
| 48 | std::cout << "\t\tTimerManager test00" << std::endl; |
| 49 | |
| 50 | TimerManagerTests timerManagerTests; |
| 51 | |
| 52 | assert(timerManagerTests.test00()); |
| 53 | } |
Marc Slemko | d466b21 | 2006-07-20 00:04:18 +0000 | [diff] [blame] | 54 | |
| 55 | if(runAll || arg.compare("thread-manager") == 0) { |
| 56 | |
| 57 | std::cout << "ThreadManager tests..." << std::endl; |
| 58 | |
Marc Slemko | 9d4a3e2 | 2006-07-21 19:53:48 +0000 | [diff] [blame] | 59 | size_t workerCount = 100; |
Marc Slemko | fe5ba12e | 2006-07-20 21:16:27 +0000 | [diff] [blame] | 60 | |
Marc Slemko | 9d4a3e2 | 2006-07-21 19:53:48 +0000 | [diff] [blame] | 61 | size_t taskCount = 100000; |
Marc Slemko | fe5ba12e | 2006-07-20 21:16:27 +0000 | [diff] [blame] | 62 | |
| 63 | long long delay = 10LL; |
| 64 | |
| 65 | std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl; |
Marc Slemko | d466b21 | 2006-07-20 00:04:18 +0000 | [diff] [blame] | 66 | |
| 67 | ThreadManagerTests threadManagerTests; |
| 68 | |
Marc Slemko | fe5ba12e | 2006-07-20 21:16:27 +0000 | [diff] [blame] | 69 | assert(threadManagerTests.loadTest(taskCount, delay, workerCount)); |
Marc Slemko | d466b21 | 2006-07-20 00:04:18 +0000 | [diff] [blame] | 70 | } |
Marc Slemko | 8a40a76 | 2006-07-19 17:46:50 +0000 | [diff] [blame] | 71 | } |
| 72 | |