Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
TestManager.cpp@9:3ff68422f4d7, 2012-08-24 (annotated)
- Committer:
- ashleymills
- Date:
- Fri Aug 24 10:42:44 2012 +0000
- Revision:
- 9:3ff68422f4d7
- Parent:
- 7:ec0db221f897
- Child:
- 13:8b69853966f8
Merge
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ashleymills | 2:ea883307d02f | 1 | #include "TestManager.h" |
ashleymills | 3:28336c2e94e4 | 2 | #include "Tests.h" |
ashleymills | 2:ea883307d02f | 3 | TestManager::TestManager(VodafoneUSBModem *m) : _modem(m) { |
ashleymills | 9:3ff68422f4d7 | 4 | //_tests.push_back((VodafoneTestCase*)new Test12(_modem)); |
ashleymills | 3:28336c2e94e4 | 5 | _tests.push_back((VodafoneTestCase*)new Test20(_modem)); |
ashleymills | 9:3ff68422f4d7 | 6 | _tests.push_back((VodafoneTestCase*)new Test50(_modem)); |
ashleymills | 2:ea883307d02f | 7 | } |
ashleymills | 2:ea883307d02f | 8 | |
ashleymills | 2:ea883307d02f | 9 | int TestManager::runAll() { |
ashleymills | 2:ea883307d02f | 10 | int successfullTests = 0; |
ashleymills | 2:ea883307d02f | 11 | LOG("Running %d tests...",_tests.size()); |
ashleymills | 2:ea883307d02f | 12 | for(int i=0; i<_tests.size(); i++) { |
ashleymills | 2:ea883307d02f | 13 | LOG("Running test %d...",i); |
ashleymills | 4:1f8e079924ba | 14 | if(_tests[i]->run()) { |
ashleymills | 2:ea883307d02f | 15 | LOG("...OK"); |
ashleymills | 2:ea883307d02f | 16 | successfullTests++; |
ashleymills | 2:ea883307d02f | 17 | } else { |
ashleymills | 2:ea883307d02f | 18 | LOG("...FAIL"); |
ashleymills | 2:ea883307d02f | 19 | } |
ashleymills | 2:ea883307d02f | 20 | } |
ashleymills | 2:ea883307d02f | 21 | return successfullTests; |
ashleymills | 2:ea883307d02f | 22 | } |
ashleymills | 2:ea883307d02f | 23 | |
ashleymills | 4:1f8e079924ba | 24 | bool TestManager::runTest(int id) { |
ashleymills | 4:1f8e079924ba | 25 | if(id<0||id>=_tests.size()) { |
ashleymills | 4:1f8e079924ba | 26 | LOG("Test ID must be between 0 and %d",_tests.size()); |
ashleymills | 4:1f8e079924ba | 27 | } |
ashleymills | 4:1f8e079924ba | 28 | return _tests[id]->run(); |
ashleymills | 4:1f8e079924ba | 29 | } |
ashleymills | 4:1f8e079924ba | 30 | |
ashleymills | 4:1f8e079924ba | 31 | |
ashleymills | 4:1f8e079924ba | 32 | bool TestManager::runTest(int id, int numTimes) { |
ashleymills | 4:1f8e079924ba | 33 | for(int i=0; i<numTimes; i++) { |
ashleymills | 4:1f8e079924ba | 34 | if(!runTest(id)) |
ashleymills | 4:1f8e079924ba | 35 | return false; |
ashleymills | 4:1f8e079924ba | 36 | } |
ashleymills | 4:1f8e079924ba | 37 | return true; |
ashleymills | 4:1f8e079924ba | 38 | } |
ashleymills | 4:1f8e079924ba | 39 | |
ashleymills | 2:ea883307d02f | 40 | int TestManager::getNumTests() { |
ashleymills | 2:ea883307d02f | 41 | return _tests.size(); |
ashleymills | 2:ea883307d02f | 42 | } |