Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
nherriot
Date:
Wed Sep 12 09:53:40 2012 +0000
Revision:
29:c0e6f198db84
Parent:
28:c630a04a7198
Child:
30:dd2beda340c6
adding some 'error' scenario test cases and many small changes to the test suite

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ashleymills 2:ea883307d02f 1 #include "TestManager.h"
ashleymills 3:28336c2e94e4 2 #include "Tests.h"
ashleymills 19:26fbed33d4e7 3 TestManager::TestManager(VodafoneUSBModem *m) : _modem(m) {
ashleymills 19:26fbed33d4e7 4 // using direct array indexing instead of searching each time, so need to put in dummy tests
ashleymills 23:408199b5d2cb 5 for(int i=0; i<10; i++) { _tests.push_back(NULL); }
ashleymills 23:408199b5d2cb 6
ashleymills 23:408199b5d2cb 7 _tests.push_back((VodafoneTestCase*)new Test10(_modem,10));
ashleymills 23:408199b5d2cb 8
ashleymills 23:408199b5d2cb 9 for(int i=11; i<12; i++) { _tests.push_back(NULL); }
ashleymills 20:18373fb68ad7 10 _tests.push_back((VodafoneTestCase*)new Test12(_modem,12));
ashleymills 20:18373fb68ad7 11 _tests.push_back((VodafoneTestCase*)new Test13(_modem,13));
ashleymills 23:408199b5d2cb 12
nherriot 28:c630a04a7198 13 for(int i=14; i<16; i++) { _tests.push_back(NULL); }
nherriot 28:c630a04a7198 14 _tests.push_back((VodafoneTestCase*)new Test16(_modem,16));
nherriot 28:c630a04a7198 15
nherriot 28:c630a04a7198 16 for(int i=17; i<21; i++) { _tests.push_back(NULL); }
ashleymills 23:408199b5d2cb 17
ashleymills 20:18373fb68ad7 18 _tests.push_back((VodafoneTestCase*)new Test21(_modem,21));
ashleymills 20:18373fb68ad7 19 _tests.push_back((VodafoneTestCase*)new Test22(_modem,22));
ashleymills 20:18373fb68ad7 20 _tests.push_back((VodafoneTestCase*)new Test23(_modem,23));
ashleymills 23:408199b5d2cb 21
ashleymills 23:408199b5d2cb 22 for(int i=24; i<25; i++) { _tests.push_back(NULL); }
ashleymills 23:408199b5d2cb 23
ashleymills 22:5b1feecf2aeb 24 _tests.push_back((VodafoneTestCase*)new Test25(_modem,25));
ashleymills 22:5b1feecf2aeb 25 _tests.push_back((VodafoneTestCase*)new Test26(_modem,26));
ashleymills 23:408199b5d2cb 26
ashleymills 23:408199b5d2cb 27 for(int i=27; i<50; i++) { _tests.push_back(NULL); }
ashleymills 23:408199b5d2cb 28
ashleymills 20:18373fb68ad7 29 _tests.push_back((VodafoneTestCase*)new Test50(_modem,50));
nherriot 29:c0e6f198db84 30 _tests.push_back((VodafoneTestCase*)new Test56(_modem,45));
ashleymills 2:ea883307d02f 31 }
ashleymills 2:ea883307d02f 32
ashleymills 22:5b1feecf2aeb 33 int TestManager::getTestProfileLength(TestProfile profile) {
ashleymills 22:5b1feecf2aeb 34 if(profile>=0 && profile <TESTS_END) {
ashleymills 22:5b1feecf2aeb 35 return gTestProfileLengths[profile];
ashleymills 22:5b1feecf2aeb 36 } else {
ashleymills 22:5b1feecf2aeb 37 LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1);
ashleymills 22:5b1feecf2aeb 38 return 0;
ashleymills 22:5b1feecf2aeb 39 }
ashleymills 22:5b1feecf2aeb 40 }
ashleymills 22:5b1feecf2aeb 41
ashleymills 22:5b1feecf2aeb 42 int TestManager::executeTestProfile(TestProfile profile) {
ashleymills 22:5b1feecf2aeb 43 if(profile>=0 && profile <TESTS_END) {
nherriot 29:c0e6f198db84 44 LOG("Test profile being used is: %d", gTestProfiles[profile]);
nherriot 29:c0e6f198db84 45 LOG("Test profile lengths being used is: %d", gTestProfileLengths[profile]);
ashleymills 22:5b1feecf2aeb 46 return executeTestList(gTestProfiles[profile], gTestProfileLengths[profile]);
ashleymills 22:5b1feecf2aeb 47 } else {
ashleymills 22:5b1feecf2aeb 48 LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1);
ashleymills 22:5b1feecf2aeb 49 return 0;
ashleymills 22:5b1feecf2aeb 50 }
ashleymills 22:5b1feecf2aeb 51 }
ashleymills 22:5b1feecf2aeb 52
ashleymills 19:26fbed33d4e7 53 int TestManager::executeTestList(const int *list, const int listLen) {
nherriot 29:c0e6f198db84 54 LOG("The executeTestList is: %d", list);
nherriot 29:c0e6f198db84 55 LOG("The executeTestListLength is: %d", listLen);
ashleymills 2:ea883307d02f 56 int successfullTests = 0;
ashleymills 19:26fbed33d4e7 57 LOG("Running %d tests...",listLen);
ashleymills 19:26fbed33d4e7 58 for(int i=0; i<listLen; i++) {
ashleymills 19:26fbed33d4e7 59 int testIndex = list[i];
ashleymills 19:26fbed33d4e7 60 LOG("Running test %d...",testIndex);
ashleymills 19:26fbed33d4e7 61 if(testIndex>=_tests.size()) {
ashleymills 19:26fbed33d4e7 62 LOG("Test out of bounds. Test index must be betweeen 0 and %d!",_tests.size());
ashleymills 19:26fbed33d4e7 63 continue;
ashleymills 19:26fbed33d4e7 64 }
ashleymills 19:26fbed33d4e7 65
ashleymills 19:26fbed33d4e7 66 VodafoneTestCase* test = _tests[list[i]];
ashleymills 19:26fbed33d4e7 67 if(test==NULL) {
ashleymills 19:26fbed33d4e7 68 LOG("NULL test! This will be counted as a failure.");
ashleymills 19:26fbed33d4e7 69 continue;
ashleymills 19:26fbed33d4e7 70 }
ashleymills 19:26fbed33d4e7 71
ashleymills 19:26fbed33d4e7 72 if(test->run()) {
ashleymills 2:ea883307d02f 73 LOG("...OK");
ashleymills 2:ea883307d02f 74 successfullTests++;
ashleymills 2:ea883307d02f 75 } else {
ashleymills 2:ea883307d02f 76 LOG("...FAIL");
ashleymills 2:ea883307d02f 77 }
ashleymills 2:ea883307d02f 78 }
ashleymills 2:ea883307d02f 79 return successfullTests;
ashleymills 2:ea883307d02f 80 }
ashleymills 2:ea883307d02f 81
ashleymills 4:1f8e079924ba 82 bool TestManager::runTest(int id) {
ashleymills 4:1f8e079924ba 83 if(id<0||id>=_tests.size()) {
ashleymills 4:1f8e079924ba 84 LOG("Test ID must be between 0 and %d",_tests.size());
ashleymills 19:26fbed33d4e7 85 return false;
ashleymills 4:1f8e079924ba 86 }
ashleymills 19:26fbed33d4e7 87 if(_tests[id]==NULL) {
ashleymills 19:26fbed33d4e7 88 LOG("NULL test! This will be counted as a failure.");
ashleymills 19:26fbed33d4e7 89 return false;
ashleymills 19:26fbed33d4e7 90 }
ashleymills 19:26fbed33d4e7 91
ashleymills 4:1f8e079924ba 92 return _tests[id]->run();
ashleymills 4:1f8e079924ba 93 }
ashleymills 4:1f8e079924ba 94
ashleymills 4:1f8e079924ba 95
ashleymills 4:1f8e079924ba 96 bool TestManager::runTest(int id, int numTimes) {
ashleymills 4:1f8e079924ba 97 for(int i=0; i<numTimes; i++) {
ashleymills 4:1f8e079924ba 98 if(!runTest(id))
ashleymills 4:1f8e079924ba 99 return false;
ashleymills 4:1f8e079924ba 100 }
ashleymills 4:1f8e079924ba 101 return true;
ashleymills 2:ea883307d02f 102 }