Unit Test: Fixed failure of test_HTTP

From Scott (xDraconian)
This commit is contained in:
James Turner 2015-03-24 11:10:16 -05:00
parent 0e9948f9d4
commit 72ae14227e
2 changed files with 11 additions and 4 deletions

View 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) {

View 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;