Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Revision 37:847f5f86e9ff, committed 2012-09-13
- Comitter:
- ashleymills
- Date:
- Thu Sep 13 15:26:49 2012 +0000
- Parent:
- 35:6867af70c51c
- Child:
- 38:83085bfd1018
- Commit message:
- Test only constructed when executed. INCOMPLETE, need to change som e other stuff to reflect this.
Changed in this revision
--- a/TestManager.cpp Thu Sep 13 12:17:18 2012 +0000 +++ b/TestManager.cpp Thu Sep 13 15:26:49 2012 +0000 @@ -6,20 +6,89 @@ _tests.push_back(testCase); } +VodafoneTestCase* TestManager::constructTest(int testID) { + switch(testID) { + case 0: break; + case 1: break; + case 2: break; + case 3: break; + case 4: break; + case 5: break; + case 6: break; + case 7: break; + case 8: break; + case 9: break; + case 10: return (VodafoneTestCase*) new Test10(_modem); + case 11: break; + case 12: return (VodafoneTestCase*) new Test12(_modem); + case 13: return (VodafoneTestCase*) new Test13(_modem); + case 14: return (VodafoneTestCase*) new Test14(_modem); + case 15: break; + case 16: return (VodafoneTestCase*) new Test16(_modem); + case 17: break; + case 18: break; + case 19: break; + case 20: break; + case 21: return (VodafoneTestCase*) new Test21(_modem); + case 22: return (VodafoneTestCase*) new Test22(_modem); + case 23: return (VodafoneTestCase*) new Test23(_modem); + case 24: break; + case 25: return (VodafoneTestCase*) new Test25(_modem); + case 26: return (VodafoneTestCase*) new Test26(_modem); + case 27: break; + case 28: break; + case 29: break; + case 30: break; + case 31: break; + case 32: break; + case 33: break; + case 34: break; + case 35: break; + case 36: break; + case 37: break; + case 38: break; + case 39: break; + case 40: break; + case 41: break; + case 42: break; + case 43: break; + case 44: break; + case 45: break; + case 46: break; + case 47: break; + case 48: break; + case 49: break; + case 50: return (VodafoneTestCase*) new Test50(_modem); + case 51: break; + case 52: break; + case 53: break; + case 54: break; + case 55: break; + case 56: return (VodafoneTestCase*) new Test56(_modem); + case 57: break; + case 58: break; + case 59: break; + }; +} + TestManager::TestManager(VodafoneUSBModem *m) : _modem(m) { // using direct array indexing instead of searching each time // dummy tests are inserted by the addTest function - _tests.push_back((VodafoneTestCase*)new Test10(m)); - addTest((VodafoneTestCase*)new Test12(m)); - addTest((VodafoneTestCase*)new Test13(m)); - addTest((VodafoneTestCase*)new Test16(m)); - addTest((VodafoneTestCase*)new Test21(m)); - addTest((VodafoneTestCase*)new Test22(m)); - addTest((VodafoneTestCase*)new Test23(m)); + //addTest((VodafoneTestCase*)new Test10(m)); + //addTest((VodafoneTestCase*)new Test12(m)); + + //addTest((VodafoneTestCase*)new Test13(m)); + //addTest((VodafoneTestCase*)new Test16(m)); + //addTest((VodafoneTestCase*)new Test21(m)); + + //addTest((VodafoneTestCase*)new Test22(m)); + //addTest((VodafoneTestCase*)new Test23(m)); + /* addTest((VodafoneTestCase*)new Test25(m)); addTest((VodafoneTestCase*)new Test26(m)); addTest((VodafoneTestCase*)new Test50(m)); addTest((VodafoneTestCase*)new Test56(m)); + */ } int TestManager::getTestProfileLength(TestProfile profile) { @@ -75,34 +144,32 @@ LOG("Running %d tests...",listLen); for(int i=0; i<listLen; i++) { int testIndex = list[i]; - VodafoneTestCase* test = getTest(testIndex); - if(test==NULL) { - LOG("Error. Test %d is not in test list! This will be counted as a failure.",testIndex); - continue; - } - - LOG("Running test %d...",testIndex); - if(test->execute()) { - LOG("...OK"); + if(executeTest(testIndex)) { successfullTests++; - } else { - LOG("...FAIL"); } } return successfullTests; } -bool TestManager::executeTest(int id) { - VodafoneTestCase* test = getTest(id); +bool TestManager::executeTest(int testID) { + VodafoneTestCase* test = constructTest(testID);//getTest(testID); if(test==NULL) { - LOG("Error. Test %d is not in test list! This will be counted as a failure.",id); + LOG("Error. Test %d is not in test list! This will be counted as a failure.",testID); + delete test; return false; } - - return _tests[id]->execute(); + + LOG("Running test %d...",testID); + if(test->execute()) { + LOG("...OK"); + delete test; + return true; + } + LOG("...FAIL"); + delete test; + return false; } - bool TestManager::executeTest(int id, int numTimes) { for(int i=0; i<numTimes; i++) { if(!executeTest(id))
--- a/TestManager.h Thu Sep 13 12:17:18 2012 +0000 +++ b/TestManager.h Thu Sep 13 15:26:49 2012 +0000 @@ -22,6 +22,8 @@ int executeTestProfile(TestProfile profile); int executeTestList(const int *list, const int listLen); + VodafoneTestCase* constructTest(int id); + VodafoneTestCase* getTest(int index); int getTestProfileLength(TestProfile profile);
--- a/Tests/Test10.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test10.h Thu Sep 13 15:26:49 2012 +0000 @@ -1,8 +1,8 @@ #pragma once #include "VodafoneTestCase.h" #include "HTTPClient.h" +extern const char *gTest10Description; -static const char* gTest10Description = "Connects to internet and downloads 100 byte file."; //const int gTest10Depends[] = {}; class Test10 : public VodafoneTestCase {
--- a/Tests/Test12.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test12.h Thu Sep 13 15:26:49 2012 +0000 @@ -10,8 +10,7 @@ // it waits forever for an SMS. // TODO: this should wait for a set time before failing. -static const char *gTest12Description = "Waiting for an SMS message with basic characters and numbers..."; - +extern const char *gTest12Description; class Test12 : public VodafoneTestCase { public:
--- a/Tests/Test13.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test13.h Thu Sep 13 15:26:49 2012 +0000 @@ -10,7 +10,7 @@ // it waits forever for an SMS. // TODO: this should wait for a set time before failing. -static const char *gTest13Description = "Waiting for an SMS message with irregular characters and numbers"; +extern const char *gTest13Description; class Test13 : public VodafoneTestCase { public:
--- a/Tests/Test14.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test14.h Thu Sep 13 15:26:49 2012 +0000 @@ -8,8 +8,7 @@ // it does not wait after it has succesfully sent an SMS. // this test basic characters and numbers can be sent via SMS. -static const char *gTest14Description = "Send an SMS message with irregular characters and numbers..."; - +extern const char *gTest14Description; class Test14 : public VodafoneTestCase { public:
--- a/Tests/Test16.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test16.h Thu Sep 13 15:26:49 2012 +0000 @@ -9,7 +9,7 @@ // this test basic characters and numbers can be sent via SMS. -static const char *gTest16Description = "Send an SMS message with basic characters and numbers..."; +extern const char *gTest16Description; class Test16 : public VodafoneTestCase { public:
--- a/Tests/Test21.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test21.h Thu Sep 13 15:26:49 2012 +0000 @@ -1,7 +1,7 @@ #pragma once #include "VodafoneTestCase.h" -static const char* gTest21Description = "Trying out USSD communication sending *#100#"; +extern const char* gTest21Description; //const int gTest21Depends[] = {}; class Test21 : public VodafoneTestCase { @@ -16,7 +16,7 @@ } virtual bool execute() { - LOG(gTest21Description); + LOG(_description); if(_modem->sendUSSD("*#100#",_ussdResponse,16)!=0) { LOG("Error sending USSD");
--- a/Tests/Test22.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test22.h Thu Sep 13 15:26:49 2012 +0000 @@ -1,7 +1,6 @@ #pragma once #include "VodafoneTestCase.h" -static const char* gTest22Description = "Sending BAD USSD string \".2890\""; -//const int gTest22Depends[] = {}; +extern const char* gTest22Description; class Test22 : public VodafoneTestCase { public: @@ -15,7 +14,7 @@ } virtual bool execute() { - LOG(gTest22Description); + LOG(_description); if(_modem->sendUSSD(".2890",_ussdResponse,16)!=0) { LOG("Error sending USSD");
--- a/Tests/Test23.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test23.h Thu Sep 13 15:26:49 2012 +0000 @@ -1,8 +1,7 @@ #pragma once #include "VodafoneTestCase.h" -static const char *gTest23Description = "Sending USSD over 150 chars \"0(0)00 ... 000(160)\""; -//const int gTest23Depends[] = {}; +extern const char *gTest23Description; class Test23 : public VodafoneTestCase { public:
--- a/Tests/Test25.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test25.h Thu Sep 13 15:26:49 2012 +0000 @@ -1,7 +1,7 @@ #pragma once #include "VodafoneTestCase.h" -static const char* gTest25Description = "Retrieve signal strength and print it."; -//const int gTest25Depends[] = {}; + +extern const char* gTest25Description; class Test25 : public VodafoneTestCase { public:
--- a/Tests/Test26.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test26.h Thu Sep 13 15:26:49 2012 +0000 @@ -1,8 +1,7 @@ #pragma once #include "VodafoneTestCase.h" -static const char* gTest26Description = "x30 -> Retrieve signal strength and print it."; -//const int gTest26Depends[] = {}; +extern const char* gTest26Description; class Test26 : public VodafoneTestCase { public:
--- a/Tests/Test50.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test50.h Thu Sep 13 15:26:49 2012 +0000 @@ -1,8 +1,7 @@ #pragma once #include "VodafoneTestCase.h" -static const char* gTest50Description = "x10 -> Retreive MSISDN and send SMS to self"; -//const int gTest50Depends[] = {}; +extern const char* gTest50Description; class Test50 : public VodafoneTestCase { public:
--- a/Tests/Test56.h Thu Sep 13 12:17:18 2012 +0000 +++ b/Tests/Test56.h Thu Sep 13 15:26:49 2012 +0000 @@ -6,7 +6,7 @@ // if the method that sends a message returns an error it will fail. // it will report the test as failed if any of the above happens. // it does not wait after it has succesfully sent an SMS. -static const char* gTest56Description = "Wait for SMS. Send a response."; +extern const char* gTest56Description; class Test56 : public VodafoneTestCase { public:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tests/Tests.cpp Thu Sep 13 15:26:49 2012 +0000 @@ -0,0 +1,14 @@ +#include "Tests.h" +// put all of the descriptions on one place for easy reference +const char* gTest10Description = "Connects to internet and downloads 100 byte file."; +const char* gTest12Description = "Sends and SMS and then does something."; +const char* gTest13Description = "Waiting for an SMS message with irregular characters and numbers"; +const char* gTest14Description = "Send an SMS message with irregular characters and numbers..."; +const char* gTest16Description = "Send an SMS message with basic characters and numbers..."; +const char* gTest21Description = "Trying out USSD communication sending *#100#"; +const char* gTest22Description = "Sending BAD USSD string \".2890\""; +const char *gTest23Description = "Sending USSD over 150 chars \"0(0)00 ... 000(160)\""; +const char* gTest25Description = "Retrieve signal strength and print it."; +const char* gTest26Description = "x30 -> Retrieve signal strength and print it."; +const char* gTest50Description = "x10 -> Retreive MSISDN and send SMS to self"; +const char* gTest56Description = "Wait for SMS. Send a response."; \ No newline at end of file
--- a/main.cpp Thu Sep 13 12:17:18 2012 +0000 +++ b/main.cpp Thu Sep 13 15:26:49 2012 +0000 @@ -31,10 +31,19 @@ } } +int* getStack() { + int dummy; + return &dummy; +} + void test(void const*) { VodafoneUSBModem modem; LOG("Constructing TestManager"); TestManager *m = new TestManager(&modem); + int *heap = (int*)malloc(8*sizeof(int)); + int *stack = getStack(); + + LOG("heap: %d, stack: %d, size: %d",heap,stack,stack-heap); LOG("Running tests."); int numPassed = m->executeTestProfile(TESTS_AUTOMATED); loopForever();