Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Files at this revision

API Documentation at this revision

Comitter:
ashleymills
Date:
Wed Sep 05 14:47:44 2012 +0000
Parent:
21:3875fe74d358
Child:
23:408199b5d2cb
Commit message:
Modified test suite for proper profiling. Added two more tests for signal strength.

Changed in this revision

TestManager.cpp Show annotated file Show diff for this revision Revisions of this file
TestManager.h Show annotated file Show diff for this revision Revisions of this file
Tests/Test25.h Show annotated file Show diff for this revision Revisions of this file
Tests/Test26.h Show annotated file Show diff for this revision Revisions of this file
Tests/Tests.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/TestManager.cpp	Tue Sep 04 15:36:59 2012 +0000
+++ b/TestManager.cpp	Wed Sep 05 14:47:44 2012 +0000
@@ -13,12 +13,35 @@
    _tests.push_back((VodafoneTestCase*)new Test21(_modem,21));
    _tests.push_back((VodafoneTestCase*)new Test22(_modem,22));
    _tests.push_back((VodafoneTestCase*)new Test23(_modem,23));
-   for(int i=24; i<50; i++) {
+   for(int i=24; i<25; i++) {
+      _tests.push_back(NULL);
+   }
+   _tests.push_back((VodafoneTestCase*)new Test25(_modem,25));
+   _tests.push_back((VodafoneTestCase*)new Test26(_modem,26));
+   for(int i=27; i<50; i++) {
       _tests.push_back(NULL);
    }
    _tests.push_back((VodafoneTestCase*)new Test50(_modem,50));
 }
 
+int TestManager::getTestProfileLength(TestProfile profile) {
+    if(profile>=0 && profile <TESTS_END) {
+      return gTestProfileLengths[profile];
+   } else {
+      LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1);
+      return 0;
+   }
+}
+
+int TestManager::executeTestProfile(TestProfile profile) {
+   if(profile>=0 && profile <TESTS_END) {
+      return executeTestList(gTestProfiles[profile], gTestProfileLengths[profile]);
+   } else {
+      LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1);
+      return 0;
+   }
+}
+
 int TestManager::executeTestList(const int *list, const int listLen) {
    int successfullTests = 0;
    LOG("Running %d tests...",listLen);
--- a/TestManager.h	Tue Sep 04 15:36:59 2012 +0000
+++ b/TestManager.h	Wed Sep 05 14:47:44 2012 +0000
@@ -1,6 +1,7 @@
 #pragma once
 #include "VodafoneUSBModem.h"
 #include "VodafoneTestCase.h"
+#include "Tests.h"
 #include <vector>
 
 enum TestNames {
@@ -14,6 +15,8 @@
       TestManager(VodafoneUSBModem *m);
       void addTest(VodafoneTestCase *tc);
       int executeTestList(const int *list, const int listLen);
+      int executeTestProfile(TestProfile profile);
+      int getTestProfileLength(TestProfile profile);
       bool runTest(int id);
       bool runTest(int id, int numTimes);
       
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tests/Test25.h	Wed Sep 05 14:47:44 2012 +0000
@@ -0,0 +1,92 @@
+#pragma once
+#include "VodafoneTestCase.h"
+class Test25 : public VodafoneTestCase {
+   public: 
+      Test25(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) {
+      }
+      
+      virtual void setupTest() {
+         _ussdResponse = (char*)malloc(16*sizeof(char));
+      }
+   
+      virtual bool runTest() {
+
+         LOG("Test %d, getting signal strength.", _testCaseNumber);
+         int rssi = -1000;
+         LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN;
+         LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN;
+        
+         if(_modem->getLinkState(&rssi, &regState, &bearer)==0) {
+            if(rssi==-1000) {
+               LOG("RSSI: Error.");
+               return false;
+            } else {
+               LOG("RSSI: %d",rssi);
+            }
+            
+            switch(regState) {
+               case LinkMonitor::REGISTRATION_STATE_UNKNOWN:
+                  LOG("regState: UNKNOWN. Failing.");
+                  return false;
+                  break;
+               case LinkMonitor::REGISTRATION_STATE_REGISTERING:
+                  LOG("regState: REGISTERING");
+                  break;
+               case LinkMonitor::REGISTRATION_STATE_DENIED:
+                  LOG("regState: DENIED");
+                  break;
+               case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL:
+                  LOG("regState: NO SIGNAL");
+                  break;
+               case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK:
+                  LOG("regState: HOME NETWORK");
+                  break;
+               case LinkMonitor::REGISTRATION_STATE_ROAMING:
+                  LOG("regState: ROAMING");
+                  break;
+               default:
+                  LOG("regState: ERROR. Failing.");
+                  return false;
+                  break;
+            }
+            
+            switch(bearer) {
+               case LinkMonitor::BEARER_UNKNOWN:
+                  LOG("bearer: UNKNOWN. Failing.");
+                  return false;
+                  break;
+               case LinkMonitor::BEARER_GSM:
+                  LOG("bearer: GSM");
+                  break;
+               case LinkMonitor::BEARER_EDGE:
+                  LOG("bearer: EDGE");
+                  break;
+               case LinkMonitor::BEARER_UMTS:
+                  LOG("bearer: UMTS");
+                  break;
+               case LinkMonitor::BEARER_HSPA:
+                  LOG("bearer: HSPA");
+                  break;
+               case LinkMonitor::BEARER_LTE:
+                  LOG("bearer: LTE");
+                  break;
+               default:
+                  LOG("bearer: ERROR. Failing.");
+                  return false;
+                  break;
+            }
+            
+         } else {
+            return false;
+         }
+         
+         return true;
+      }
+      
+      virtual void endTest() {
+         free(_ussdResponse);
+      }
+      
+   private:
+      char *_ussdResponse;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tests/Test26.h	Wed Sep 05 14:47:44 2012 +0000
@@ -0,0 +1,94 @@
+#pragma once
+#include "VodafoneTestCase.h"
+class Test26 : public VodafoneTestCase {
+   public: 
+      Test26(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) {
+      }
+      
+      virtual void setupTest() {
+         _ussdResponse = (char*)malloc(16*sizeof(char));
+      }
+   
+      virtual bool runTest() {
+         LOG("Test %d, getting signal strength 30 times.", _testCaseNumber);
+         for(int count=0; count<30; count++) {
+            LOG("Iteration %d of 30",count);
+            int rssi = -1000;
+            LinkMonitor::REGISTRATION_STATE regState = LinkMonitor::REGISTRATION_STATE_UNKNOWN;
+            LinkMonitor::BEARER bearer = LinkMonitor::BEARER_UNKNOWN;
+        
+            if(_modem->getLinkState(&rssi, &regState, &bearer)==0) {
+               if(rssi==-1000) {
+                  LOG("RSSI: Error.");
+                  return false;
+               } else {
+                  LOG("RSSI: %d",rssi);
+               }
+            
+               switch(regState) {
+                  case LinkMonitor::REGISTRATION_STATE_UNKNOWN:
+                     LOG("regState: UNKNOWN. Failing.");
+                     return false;
+                     break;
+                  case LinkMonitor::REGISTRATION_STATE_REGISTERING:
+                     LOG("regState: REGISTERING");
+                     break;
+                  case LinkMonitor::REGISTRATION_STATE_DENIED:
+                     LOG("regState: DENIED");
+                     break;
+                  case LinkMonitor::REGISTRATION_STATE_NO_SIGNAL:
+                     LOG("regState: NO SIGNAL");
+                     break;
+                  case LinkMonitor::REGISTRATION_STATE_HOME_NETWORK:
+                     LOG("regState: HOME NETWORK");
+                     break;
+                  case LinkMonitor::REGISTRATION_STATE_ROAMING:
+                     LOG("regState: ROAMING");
+                     break;
+                  default:
+                     LOG("regState: ERROR. Failing.");
+                     return false;
+                     break;
+               }
+            
+               switch(bearer) {
+                  case LinkMonitor::BEARER_UNKNOWN:
+                     LOG("bearer: UNKNOWN. Failing.");
+                     return false;
+                     break;
+                  case LinkMonitor::BEARER_GSM:
+                     LOG("bearer: GSM");
+                     break;
+                  case LinkMonitor::BEARER_EDGE:
+                     LOG("bearer: EDGE");
+                     break;
+                  case LinkMonitor::BEARER_UMTS:
+                     LOG("bearer: UMTS");
+                     break;
+                  case LinkMonitor::BEARER_HSPA:
+                     LOG("bearer: HSPA");
+                     break;
+                  case LinkMonitor::BEARER_LTE:
+                     LOG("bearer: LTE");
+                     break;
+                  default:
+                     LOG("bearer: ERROR. Failing.");
+                     return false;
+                     break;
+               }
+            } else {
+               return false;
+            }
+         }
+         
+         return true;
+      }
+      
+      virtual void endTest() {
+         free(_ussdResponse);
+      }
+      
+   private:
+      char *_ussdResponse;
+};
+
--- a/Tests/Tests.h	Tue Sep 04 15:36:59 2012 +0000
+++ b/Tests/Tests.h	Wed Sep 05 14:47:44 2012 +0000
@@ -4,11 +4,37 @@
 #include "Test21.h"
 #include "Test22.h"
 #include "Test23.h"
+#include "Test25.h"
+#include "Test26.h"
 #include "Test50.h"
 
-const int gAutomatedTests[] = {21,22,23};
-const int gNumAutomatedTests = 3;
-const int gInteractiveTests[] = {12,13};
-const int gNumInteractiveTests = 2;
-const int gSoakTests[] = {50};
-const int gNumSoakTests = 1;
\ No newline at end of file
+static const int gAllTests[] = {12,13,21,22,23,25,26,50};
+static const int gNumAllTests = 8;
+static const int gAutomatedTests[] = {21,22,23,25};
+static const int gNumAutomatedTests = 4;
+static const int gInteractiveTests[] = {12,13,26};
+static const int gNumInteractiveTests = 3;
+static const int gSoakTests[] = {50};
+static const int gNumSoakTests = 1;
+
+enum TestProfile {
+   TESTS_ALL,
+   TESTS_AUTOMATED,
+   TESTS_MANUAL,
+   TESTS_SOAK,
+   TESTS_END
+};
+
+static const int* gTestProfiles[4] = {
+   (const int*)&gAllTests,
+   (const int*)&gAutomatedTests,
+   (const int*)&gInteractiveTests,
+   (const int*)&gSoakTests
+};
+
+static const int gTestProfileLengths[4] = {
+   gNumAllTests,
+   gNumAutomatedTests,
+   gNumInteractiveTests,
+   gNumSoakTests
+};
\ No newline at end of file
--- a/main.cpp	Tue Sep 04 15:36:59 2012 +0000
+++ b/main.cpp	Wed Sep 05 14:47:44 2012 +0000
@@ -11,7 +11,6 @@
 #include "VodafoneUSBModem.h"
 #include "VodafoneTestCase.h"
 #include "TestManager.h"
-#include "Tests.h"
 
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
@@ -24,11 +23,11 @@
   VodafoneUSBModem modem;
   LOG("Constructing TestManager");
   TestManager *m = new TestManager(&modem);
-  LOG("Running all automated tests");
-  
-  int numPassed = m->executeTestList(gAutomatedTests,gNumAutomatedTests);
-  LOG("%d tests complete: %d passes and %d failures.",
-     gNumAutomatedTests,numPassed,gNumAutomatedTests-numPassed);
+  LOG("Running tests.");
+  TestProfile profile = TESTS_AUTOMATED;
+  int numPassed = m->executeTestProfile(profile);
+  int numTests = m->getTestProfileLength(profile);
+  LOG("%d tests complete: %d passes and %d failures.",numTests,numPassed,numTests-numPassed);
   
   while(1) {
      Thread::wait(1000);