]> git.mxchange.org Git - simgear.git/commitdiff
Unit Test: Fixed failure of test_HTTP
authorJames Turner <zakalawe@mac.com>
Tue, 24 Mar 2015 16:10:16 +0000 (11:10 -0500)
committerJames Turner <zakalawe@mac.com>
Tue, 24 Mar 2015 16:10:16 +0000 (11:10 -0500)
From Scott (xDraconian)

simgear/io/sg_netChannel.cxx
simgear/io/test_HTTP.cxx

index e62e120ad173c3240e3a7a25151a03636b38fd25..1561e8de464bbbc83413915f1b53d82ec2367727 100644 (file)
@@ -251,6 +251,11 @@ NetChannelPoller::removeChannel(NetChannel* channel)
     assert(channel->poller == this);
     channel->poller = NULL;
     
+    // portability: MSVC throws assertion failure when empty
+    if (channels.empty()) {
+        return;
+    }
+
     ChannelList::iterator it = channels.begin();
     for (; it != channels.end(); ++it) {
         if (*it == channel) {
index 1849434d55d59f6d3d032810bedc9376343f67dc..ea57837b4f04fb18ca6b5d4206337203eb559f87 100644 (file)
@@ -379,6 +379,8 @@ class TestServer : public NetChannel
 public:   
     TestServer()
     {
+        Socket::initSockets();
+
         open();
         bind(NULL, 2000); // localhost, any port
         listen(5);
@@ -414,14 +416,14 @@ TestServer testServer;
 void waitForComplete(HTTP::Client* cl, TestRequest* tr)
 {
     SGTimeStamp start(SGTimeStamp::now());
-    while (start.elapsedMSec() <  1000) {
+    while (start.elapsedMSec() <  10000) {
         cl->update();
         testServer.poll();
         
         if (tr->complete) {
             return;
         }
-        SGTimeStamp::sleepForMSec(1);
+        SGTimeStamp::sleepForMSec(15);
     }
     
     cerr << "timed out" << endl;
@@ -430,14 +432,14 @@ void waitForComplete(HTTP::Client* cl, TestRequest* tr)
 void waitForFailed(HTTP::Client* cl, TestRequest* tr)
 {
     SGTimeStamp start(SGTimeStamp::now());
-    while (start.elapsedMSec() <  1000) {
+    while (start.elapsedMSec() <  10000) {
         cl->update();
         testServer.poll();
         
         if (tr->failed) {
             return;
         }
-        SGTimeStamp::sleepForMSec(1);
+        SGTimeStamp::sleepForMSec(15);
     }
     
     cerr << "timed out waiting for failure" << endl;