Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Revision 52:de6cc9d823ab, committed 2012-10-11
- Comitter:
- ashleymills
- Date:
- Thu Oct 11 10:00:19 2012 +0000
- Parent:
- 51:15ba73d1cc45
- Child:
- 53:54b2d3a0c7bf
- Commit message:
- Improved DNS test case to idenfity timeout problem.
Changed in this revision
--- a/Tests/Test08.cpp Fri Sep 21 11:29:28 2012 +0000 +++ b/Tests/Test08.cpp Thu Oct 11 10:00:19 2012 +0000 @@ -1,10 +1,40 @@ #include "Test08.h" +#include "socket.h" + +bool connectToSocket(char *ipAddress, int port, int *sockfd) { + int ret = -1; + *sockfd = -1; + // create the socket + if((*sockfd=socket(AF_INET,SOCK_STREAM,0))<0) { + LOG("Error opening socket\r\n"); + } else { + LOG("Socket open\r\n"); + } + + // create the socket address + sockaddr_in serverAddress; + std::memset(&serverAddress, 0, sizeof(struct sockaddr_in)); + serverAddress.sin_addr.s_addr = inet_addr(ipAddress); + serverAddress.sin_family = AF_INET; + serverAddress.sin_port = htons(port); + + // do socket connect + LOG("Connecting socket to %s:%d", inet_ntoa(serverAddress.sin_addr), ntohs(serverAddress.sin_port)); + if((ret=::connect(*sockfd, (const struct sockaddr *)&serverAddress, sizeof(serverAddress)))<0) { + ::close(*sockfd); + LOG("Could not connect"); + return false; + } else { + LOG("Connection OK"); + } + return true; +} const char *gTest08DNSIn[5] = { "m2mthings.com", "kent.ac.uk", "example.com", - "freebsd.org", + "m2mcontroller.com", "www.mbed.org", }; @@ -12,7 +42,7 @@ "109.74.199.96", "129.12.10.249", "192.0.43.10", - "69.147.83.40", + "62.105.171.138", "217.140.101.20", }; @@ -35,6 +65,14 @@ LOG("Failed to connect to internet"); outcome = false; } + + // try connecting to DNS server directly + int sockfd; + //if(connectToSocket("88.82.13.28",53,&sockfd)) { + if(connectToSocket("109.74.199.96",80,&sockfd)) { + close(sockfd); + } + struct hostent *server; do { while(1) {
--- a/Tests/Tests.h Fri Sep 21 11:29:28 2012 +0000 +++ b/Tests/Tests.h Thu Oct 11 10:00:19 2012 +0000 @@ -15,8 +15,8 @@ const int gAllTests[] = {10,16,12,13,21,22,23,25,26,50}; const int gNumAllTests = 10; -const int gAutomatedTests[] = {8,10,21,22,23,25,26}; -const int gNumAutomatedTests = 7; +const int gAutomatedTests[] = {8,10,21,22,23,25,26,50}; +const int gNumAutomatedTests = 8; const int gInteractiveTests[] = {16,12,14,13}; const int gNumInteractiveTests = 4; const int gSoakTests[] = {50};
--- a/VodafoneUSBModem_bleedingedge.lib Fri Sep 21 11:29:28 2012 +0000 +++ b/VodafoneUSBModem_bleedingedge.lib Thu Oct 11 10:00:19 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#8bec5a8ea878 +http://mbed.org/users/donatien/code/VodafoneUSBModem_bleedingedge/#bd474c9fe51e
--- a/main.cpp Fri Sep 21 11:29:28 2012 +0000 +++ b/main.cpp Thu Oct 11 10:00:19 2012 +0000 @@ -66,7 +66,14 @@ size_t currentTime = time(NULL); fprintf(stdout,"Invocation time: %s\r\n",ctime(¤tTime)); - Thread testTask(test, NULL, osPriorityNormal, 1024 * 6); + //Thread testTask(test, NULL, osPriorityNormal, 1024 * 6); + + VodafoneUSBModem modem; + LOG("Constructing TestManager"); + LOG("Running tests."); + TestManager *m = new TestManager(&modem); + //m->runTestProfile(TESTS_AUTOMATED); + m->runTest(8); // this thread just waits and blinks leds periodically while(1) { led1 = !led1;