Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
nherriot
Date:
Wed Sep 12 16:55:00 2012 +0000
Revision:
31:9231acdde9ff
Parent:
30:dd2beda340c6
Child:
33:16126e029d58
adding new sms test cases for send/receive irregular chars. changing auto run list, and adding descriptions.

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 31:9231acdde9ff 30
nherriot 31:9231acdde9ff 31 for(int i=51; i<56; i++) { _tests.push_back(NULL); }
nherriot 31:9231acdde9ff 32
nherriot 31:9231acdde9ff 33 _tests.push_back((VodafoneTestCase*)new Test56(_modem,56));
ashleymills 2:ea883307d02f 34 }
ashleymills 2:ea883307d02f 35
ashleymills 22:5b1feecf2aeb 36 int TestManager::getTestProfileLength(TestProfile profile) {
ashleymills 26:9eefab9e28df 37 if(profile < TESTS_END) { // no test for >= 0 since TestProfile is unsigned
ashleymills 22:5b1feecf2aeb 38 return gTestProfileLengths[profile];
ashleymills 22:5b1feecf2aeb 39 } else {
ashleymills 22:5b1feecf2aeb 40 LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1);
ashleymills 22:5b1feecf2aeb 41 return 0;
ashleymills 22:5b1feecf2aeb 42 }
ashleymills 22:5b1feecf2aeb 43 }
ashleymills 22:5b1feecf2aeb 44
ashleymills 22:5b1feecf2aeb 45 int TestManager::executeTestProfile(TestProfile profile) {
nherriot 30:dd2beda340c6 46
ashleymills 24:8f0f9551122a 47 int numPassed = 0;
ashleymills 26:9eefab9e28df 48 if(profile <TESTS_END) { // no test for >= 0 since TestProfile is unsigned
ashleymills 24:8f0f9551122a 49 numPassed = executeTestList(gTestProfiles[profile], gTestProfileLengths[profile]);
nherriot 30:dd2beda340c6 50
ashleymills 22:5b1feecf2aeb 51 } else {
ashleymills 22:5b1feecf2aeb 52 LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1);
ashleymills 22:5b1feecf2aeb 53 return 0;
ashleymills 22:5b1feecf2aeb 54 }
ashleymills 24:8f0f9551122a 55 int numTests = getTestProfileLength(profile);
ashleymills 24:8f0f9551122a 56 LOG("%d tests complete: %d passes and %d failures.",numTests,numPassed,numTests-numPassed);
ashleymills 27:0297dbc3252b 57 LOG("Listing failures:");
ashleymills 27:0297dbc3252b 58 listFailures(gTestProfiles[profile], gTestProfileLengths[profile]);
ashleymills 24:8f0f9551122a 59 return numPassed;
ashleymills 22:5b1feecf2aeb 60 }
ashleymills 22:5b1feecf2aeb 61
ashleymills 27:0297dbc3252b 62 void TestManager::listFailures(const int *list, const int listLen) {
ashleymills 27:0297dbc3252b 63 int successfullTests = 0;
ashleymills 27:0297dbc3252b 64 for(int i=0; i<listLen; i++) {
ashleymills 27:0297dbc3252b 65 int testIndex = list[i];
ashleymills 27:0297dbc3252b 66 if(testIndex>=_tests.size()) {
nherriot 31:9231acdde9ff 67 LOG("Test out of bounds... Test index must be betweeen 0 and %d!",_tests.size());
ashleymills 27:0297dbc3252b 68 continue;
ashleymills 27:0297dbc3252b 69 }
ashleymills 27:0297dbc3252b 70
ashleymills 27:0297dbc3252b 71 VodafoneTestCase* test = _tests[list[i]];
ashleymills 27:0297dbc3252b 72 if(test->_lastRunOutcome==false) {
ashleymills 27:0297dbc3252b 73 LOG("Test %d:",list[i]);
ashleymills 27:0297dbc3252b 74 LOG(gTestDescriptions[list[i]]);
ashleymills 27:0297dbc3252b 75 }
ashleymills 27:0297dbc3252b 76 }
ashleymills 22:5b1feecf2aeb 77 }
ashleymills 22:5b1feecf2aeb 78
ashleymills 19:26fbed33d4e7 79 int TestManager::executeTestList(const int *list, const int listLen) {
nherriot 29:c0e6f198db84 80 LOG("The executeTestList is: %d", list);
nherriot 29:c0e6f198db84 81 LOG("The executeTestListLength is: %d", listLen);
ashleymills 2:ea883307d02f 82 int successfullTests = 0;
ashleymills 19:26fbed33d4e7 83 LOG("Running %d tests...",listLen);
ashleymills 19:26fbed33d4e7 84 for(int i=0; i<listLen; i++) {
ashleymills 19:26fbed33d4e7 85 int testIndex = list[i];
ashleymills 19:26fbed33d4e7 86 LOG("Running test %d...",testIndex);
ashleymills 19:26fbed33d4e7 87 if(testIndex>=_tests.size()) {
ashleymills 19:26fbed33d4e7 88 LOG("Test out of bounds. Test index must be betweeen 0 and %d!",_tests.size());
ashleymills 19:26fbed33d4e7 89 continue;
ashleymills 19:26fbed33d4e7 90 }
ashleymills 19:26fbed33d4e7 91
ashleymills 19:26fbed33d4e7 92 VodafoneTestCase* test = _tests[list[i]];
ashleymills 19:26fbed33d4e7 93 if(test==NULL) {
ashleymills 19:26fbed33d4e7 94 LOG("NULL test! This will be counted as a failure.");
ashleymills 19:26fbed33d4e7 95 continue;
ashleymills 19:26fbed33d4e7 96 }
ashleymills 19:26fbed33d4e7 97
ashleymills 19:26fbed33d4e7 98 if(test->run()) {
ashleymills 2:ea883307d02f 99 LOG("...OK");
ashleymills 2:ea883307d02f 100 successfullTests++;
ashleymills 2:ea883307d02f 101 } else {
ashleymills 2:ea883307d02f 102 LOG("...FAIL");
ashleymills 2:ea883307d02f 103 }
ashleymills 2:ea883307d02f 104 }
ashleymills 2:ea883307d02f 105 return successfullTests;
ashleymills 2:ea883307d02f 106 }
ashleymills 2:ea883307d02f 107
ashleymills 4:1f8e079924ba 108 bool TestManager::runTest(int id) {
ashleymills 4:1f8e079924ba 109 if(id<0||id>=_tests.size()) {
ashleymills 4:1f8e079924ba 110 LOG("Test ID must be between 0 and %d",_tests.size());
ashleymills 19:26fbed33d4e7 111 return false;
ashleymills 4:1f8e079924ba 112 }
ashleymills 19:26fbed33d4e7 113 if(_tests[id]==NULL) {
ashleymills 19:26fbed33d4e7 114 LOG("NULL test! This will be counted as a failure.");
ashleymills 19:26fbed33d4e7 115 return false;
ashleymills 19:26fbed33d4e7 116 }
ashleymills 19:26fbed33d4e7 117
ashleymills 4:1f8e079924ba 118 return _tests[id]->run();
ashleymills 4:1f8e079924ba 119 }
ashleymills 4:1f8e079924ba 120
ashleymills 4:1f8e079924ba 121
ashleymills 4:1f8e079924ba 122 bool TestManager::runTest(int id, int numTimes) {
ashleymills 4:1f8e079924ba 123 for(int i=0; i<numTimes; i++) {
ashleymills 4:1f8e079924ba 124 if(!runTest(id))
ashleymills 4:1f8e079924ba 125 return false;
ashleymills 4:1f8e079924ba 126 }
ashleymills 4:1f8e079924ba 127 return true;
ashleymills 2:ea883307d02f 128 }