Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Diff: TestManager.cpp
- Revision:
- 19:26fbed33d4e7
- Parent:
- 16:c89d426c6175
- Child:
- 20:18373fb68ad7
--- a/TestManager.cpp Thu Aug 30 14:18:16 2012 +0000 +++ b/TestManager.cpp Mon Sep 03 16:02:58 2012 +0000 @@ -1,18 +1,41 @@ #include "TestManager.h" #include "Tests.h" -TestManager::TestManager(VodafoneUSBModem *m) : _modem(m) { - _tests.push_back((VodafoneTestCase*)new Test20(_modem, 20)); +TestManager::TestManager(VodafoneUSBModem *m) : _modem(m) { + // using direct array indexing instead of searching each time, so need to put in dummy tests + for(int i=0; i<12; i++) { + _tests.push_back(NULL); + } _tests.push_back((VodafoneTestCase*)new Test12(_modem, 12)); _tests.push_back((VodafoneTestCase*)new Test13(_modem, 13)); - // _tests.push_back((VodafoneTestCase*)new Test50(_modem, 50)); + for(int i=14; i<21; i++) { + _tests.push_back(NULL); + } + _tests.push_back((VodafoneTestCase*)new Test21(_modem, 21)); + _tests.push_back((VodafoneTestCase*)new Test22(_modem, 22)); + for(int i=23; i<50; i++) { + _tests.push_back(NULL); + } + _tests.push_back((VodafoneTestCase*)new Test50(_modem, 50)); } -int TestManager::runAll() { +int TestManager::executeTestList(const int *list, const int listLen) { int successfullTests = 0; - LOG("Running %d tests...",_tests.size()); - for(int i=0; i<_tests.size(); i++) { - LOG("Running test %d...",i); - if(_tests[i]->run()) { + LOG("Running %d tests...",listLen); + for(int i=0; i<listLen; i++) { + int testIndex = list[i]; + LOG("Running test %d...",testIndex); + if(testIndex>=_tests.size()) { + LOG("Test out of bounds. Test index must be betweeen 0 and %d!",_tests.size()); + continue; + } + + VodafoneTestCase* test = _tests[list[i]]; + if(test==NULL) { + LOG("NULL test! This will be counted as a failure."); + continue; + } + + if(test->run()) { LOG("...OK"); successfullTests++; } else { @@ -25,7 +48,13 @@ bool TestManager::runTest(int id) { if(id<0||id>=_tests.size()) { LOG("Test ID must be between 0 and %d",_tests.size()); + return false; } + if(_tests[id]==NULL) { + LOG("NULL test! This will be counted as a failure."); + return false; + } + return _tests[id]->run(); } @@ -36,8 +65,4 @@ return false; } return true; -} - -int TestManager::getNumTests() { - return _tests.size(); } \ No newline at end of file