Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Committer:
nherriot
Date:
Mon Sep 10 04:59:11 2012 +0000
Revision:
28:c630a04a7198
Parent:
23:408199b5d2cb
Child:
29:c0e6f198db84
Adding details to test case 16 and 13 where each test depends on one to send and one to receive. Also removing constants to VodafoneTestCase.h to have them in one place for all tests. Created several const char strings for all test cases.

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));
ashleymills 2:ea883307d02f 30 }
ashleymills 2:ea883307d02f 31
ashleymills 22:5b1feecf2aeb 32 int TestManager::getTestProfileLength(TestProfile profile) {
ashleymills 22:5b1feecf2aeb 33 if(profile>=0 && profile <TESTS_END) {
ashleymills 22:5b1feecf2aeb 34 return gTestProfileLengths[profile];
ashleymills 22:5b1feecf2aeb 35 } else {
ashleymills 22:5b1feecf2aeb 36 LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1);
ashleymills 22:5b1feecf2aeb 37 return 0;
ashleymills 22:5b1feecf2aeb 38 }
ashleymills 22:5b1feecf2aeb 39 }
ashleymills 22:5b1feecf2aeb 40
ashleymills 22:5b1feecf2aeb 41 int TestManager::executeTestProfile(TestProfile profile) {
ashleymills 22:5b1feecf2aeb 42 if(profile>=0 && profile <TESTS_END) {
ashleymills 22:5b1feecf2aeb 43 return executeTestList(gTestProfiles[profile], gTestProfileLengths[profile]);
ashleymills 22:5b1feecf2aeb 44 } else {
ashleymills 22:5b1feecf2aeb 45 LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1);
ashleymills 22:5b1feecf2aeb 46 return 0;
ashleymills 22:5b1feecf2aeb 47 }
ashleymills 22:5b1feecf2aeb 48 }
ashleymills 22:5b1feecf2aeb 49
ashleymills 19:26fbed33d4e7 50 int TestManager::executeTestList(const int *list, const int listLen) {
ashleymills 2:ea883307d02f 51 int successfullTests = 0;
ashleymills 19:26fbed33d4e7 52 LOG("Running %d tests...",listLen);
ashleymills 19:26fbed33d4e7 53 for(int i=0; i<listLen; i++) {
ashleymills 19:26fbed33d4e7 54 int testIndex = list[i];
ashleymills 19:26fbed33d4e7 55 LOG("Running test %d...",testIndex);
ashleymills 19:26fbed33d4e7 56 if(testIndex>=_tests.size()) {
ashleymills 19:26fbed33d4e7 57 LOG("Test out of bounds. Test index must be betweeen 0 and %d!",_tests.size());
ashleymills 19:26fbed33d4e7 58 continue;
ashleymills 19:26fbed33d4e7 59 }
ashleymills 19:26fbed33d4e7 60
ashleymills 19:26fbed33d4e7 61 VodafoneTestCase* test = _tests[list[i]];
ashleymills 19:26fbed33d4e7 62 if(test==NULL) {
ashleymills 19:26fbed33d4e7 63 LOG("NULL test! This will be counted as a failure.");
ashleymills 19:26fbed33d4e7 64 continue;
ashleymills 19:26fbed33d4e7 65 }
ashleymills 19:26fbed33d4e7 66
ashleymills 19:26fbed33d4e7 67 if(test->run()) {
ashleymills 2:ea883307d02f 68 LOG("...OK");
ashleymills 2:ea883307d02f 69 successfullTests++;
ashleymills 2:ea883307d02f 70 } else {
ashleymills 2:ea883307d02f 71 LOG("...FAIL");
ashleymills 2:ea883307d02f 72 }
ashleymills 2:ea883307d02f 73 }
ashleymills 2:ea883307d02f 74 return successfullTests;
ashleymills 2:ea883307d02f 75 }
ashleymills 2:ea883307d02f 76
ashleymills 4:1f8e079924ba 77 bool TestManager::runTest(int id) {
ashleymills 4:1f8e079924ba 78 if(id<0||id>=_tests.size()) {
ashleymills 4:1f8e079924ba 79 LOG("Test ID must be between 0 and %d",_tests.size());
ashleymills 19:26fbed33d4e7 80 return false;
ashleymills 4:1f8e079924ba 81 }
ashleymills 19:26fbed33d4e7 82 if(_tests[id]==NULL) {
ashleymills 19:26fbed33d4e7 83 LOG("NULL test! This will be counted as a failure.");
ashleymills 19:26fbed33d4e7 84 return false;
ashleymills 19:26fbed33d4e7 85 }
ashleymills 19:26fbed33d4e7 86
ashleymills 4:1f8e079924ba 87 return _tests[id]->run();
ashleymills 4:1f8e079924ba 88 }
ashleymills 4:1f8e079924ba 89
ashleymills 4:1f8e079924ba 90
ashleymills 4:1f8e079924ba 91 bool TestManager::runTest(int id, int numTimes) {
ashleymills 4:1f8e079924ba 92 for(int i=0; i<numTimes; i++) {
ashleymills 4:1f8e079924ba 93 if(!runTest(id))
ashleymills 4:1f8e079924ba 94 return false;
ashleymills 4:1f8e079924ba 95 }
ashleymills 4:1f8e079924ba 96 return true;
ashleymills 2:ea883307d02f 97 }