Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Files at this revision

API Documentation at this revision

Comitter:
ashleymills
Date:
Wed Sep 19 13:59:39 2012 +0000
Parent:
46:d2c22206031a
Child:
48:c1c012604f09
Child:
49:0f059872f8e2
Commit message:
Added DNS body to test 5 addresses.

Changed in this revision

Tests/Test08.cpp Show annotated file Show diff for this revision Revisions of this file
VodafoneUSBModem_bleedingedge.lib 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/Tests/Test08.cpp	Wed Sep 19 09:52:46 2012 +0000
+++ b/Tests/Test08.cpp	Wed Sep 19 13:59:39 2012 +0000
@@ -1,5 +1,23 @@
 #include "Test08.h"
 
+const char *gTest08DNSIn[5] = {
+   "m2mthings.com",
+   "google.co.uk",
+   "example.com",
+   "freebsd.org",
+   "www.mbed.org",
+};
+
+const char *gTest08DNSOut[5] = {
+   "109.74.199.96",
+   "173.194.69.94",
+   "192.0.43.10",
+   "69.147.83.40",
+   "217.140.101.20",
+};
+
+const int gTest08NumDNSVals = 5;
+
 Test08::Test08(VodafoneUSBModem *m) : VodafoneTestCase(m) {
    _description = gTest08Description;
    _testCaseNumber = 8;
@@ -39,6 +57,7 @@
             server->h_addr[2],
             server->h_addr[3]
          );
+         outcome = true;
       } else {
          LOG("Only IPv4 addresses are supported.");
          outcome = false;
@@ -46,6 +65,45 @@
       }
    } while(0);
    
+   // this is the real test
+   
+   char dnsOut[32];
+   
+   for(int i=0; i<gTest08NumDNSVals; i++) {
+      LOG("Running DNS lookup for %s",gTest08DNSIn[i]);
+      server = ::gethostbyname(gTest08DNSIn[i]);
+      if(server==NULL) {
+         LOG("Failure getting host address!");
+         outcome = false;
+         break;
+      } else {
+         LOG("Got host address, length %d",server->h_length);
+      }
+      
+      if(server->h_length==4) {
+         sprintf(dnsOut,"%d.%d.%d.%d",
+            server->h_addr[0],
+            server->h_addr[1],
+            server->h_addr[2],
+            server->h_addr[3]
+         );
+         LOG("DNS lookup returned %s",dnsOut);
+      } else {
+         LOG("Error. Only IPv4 addresses are supported.");
+         outcome = false;
+         break;
+      }
+      
+      LOG("Expected %s, got %s",gTest08DNSOut[i],dnsOut);
+      if(strcmp(dnsOut,gTest08DNSOut[i])!=0) {
+         LOG("Mismatch. Fail.");
+         outcome = false;
+         break;
+      } else {
+         LOG("Match. OK.");
+      }
+   }
+   
    _modem->disconnect();
    return outcome;
 }
--- a/VodafoneUSBModem_bleedingedge.lib	Wed Sep 19 09:52:46 2012 +0000
+++ b/VodafoneUSBModem_bleedingedge.lib	Wed Sep 19 13:59:39 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#45c3b5cb0234
+http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#c1fd83bd31b4
--- a/main.cpp	Wed Sep 19 09:52:46 2012 +0000
+++ b/main.cpp	Wed Sep 19 13:59:39 2012 +0000
@@ -28,6 +28,7 @@
       Thread::wait(1000);
       time_t now = time(NULL);
       gPreviousUptime = gUptime;
+      gUptime = now-startTime;
    }
 }
 
@@ -36,8 +37,8 @@
   LOG("Constructing TestManager");
   LOG("Running tests.");
   TestManager *m = new TestManager(&modem);
-  m->runTestProfile(TESTS_AUTOMATED);
-  //m->runTest(8);
+  //m->runTestProfile(TESTS_AUTOMATED);
+  m->runTest(8);
   //m->executeTest(26);
   //m->executeTest(10);
   //m->executeTest(21);
@@ -46,7 +47,7 @@
 
 void setTime() {
   struct tm t;
-  t.tm_year  = 2000;
+  t.tm_year  = 100;
   t.tm_mon   = 0;
   t.tm_mday  = 0;
   t.tm_hour  = 0;