From: James Turner Date: Tue, 24 Mar 2015 16:10:16 +0000 (-0500) Subject: Unit Test: Fixed failure of test_HTTP X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=72ae14227ed3600ade36d750de5d8af4ddf3118d;p=simgear.git Unit Test: Fixed failure of test_HTTP From Scott (xDraconian) --- diff --git a/simgear/io/sg_netChannel.cxx b/simgear/io/sg_netChannel.cxx index e62e120a..1561e8de 100644 --- a/simgear/io/sg_netChannel.cxx +++ b/simgear/io/sg_netChannel.cxx @@ -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) { diff --git a/simgear/io/test_HTTP.cxx b/simgear/io/test_HTTP.cxx index 1849434d..ea57837b 100644 --- a/simgear/io/test_HTTP.cxx +++ b/simgear/io/test_HTTP.cxx @@ -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;