Fix windows (#51)

* More fixes for Windows

* fix tests for windows

* qf for linux

* clean up
This commit is contained in:
Dimon4eg
2019-05-06 22:22:57 +03:00
committed by Benjamin Sergeant
parent d561e1141e
commit 78198a0147
10 changed files with 64 additions and 58 deletions

View File

@ -32,16 +32,16 @@ set (SOURCES
IXDNSLookupTest.cpp
IXSocketTest.cpp
IXSocketConnectTest.cpp
IXWebSocketServerTest.cpp
IXWebSocketPingTest.cpp
IXWebSocketTestConnectionDisconnection.cpp
)
# Some unittest don't work on windows yet
if (NOT WIN32)
list(APPEND SOURCES
IXWebSocketServerTest.cpp
IXWebSocketPingTest.cpp
list(APPEND SOURCES
IXWebSocketPingTimeoutTest.cpp
cmd_websocket_chat.cpp
IXWebSocketTestConnectionDisconnection.cpp
)
endif()

View File

@ -108,7 +108,7 @@ namespace ix
{
log("Cannot compute a free port. bind error.");
::close(sockfd);
Socket::closeSocket(sockfd);
return getAnyFreePortRandom();
}
@ -118,12 +118,12 @@ namespace ix
{
log("Cannot compute a free port. getsockname error.");
::close(sockfd);
Socket::closeSocket(sockfd);
return getAnyFreePortRandom();
}
int port = ntohs(sa.sin_port);
::close(sockfd);
Socket::closeSocket(sockfd);
return port;
}

View File

@ -23,7 +23,6 @@ namespace
public:
WebSocketClient(int port, bool useHeartBeatMethod);
void subscribe(const std::string& channel);
void start();
void stop();
bool isReady() const;
@ -57,7 +56,7 @@ namespace
std::string url;
{
std::stringstream ss;
ss << "ws://localhost:"
ss << "ws://127.0.0.1:"
<< _port
<< "/";
@ -347,6 +346,9 @@ TEST_CASE("Websocket_ping_data_sent_setPingInterval", "[setPingInterval]")
webSocketClient.stop();
// without this sleep test fails on Windows
ix::msleep(100);
// Here we test ping interval
// client has sent data, but ping should have been sent no matter what
// -> expected ping messages == 3 as 900+900+1300 = 3100 seconds, 1 ping sent every second

View File

@ -23,7 +23,6 @@ namespace
public:
WebSocketClient(int port, int pingInterval, int pingTimeout);
void subscribe(const std::string& channel);
void start();
void stop();
bool isReady() const;
@ -71,7 +70,7 @@ namespace
std::string url;
{
std::stringstream ss;
ss << "ws://localhost:"
ss << "ws://127.0.0.1:"
<< _port
<< "/";

View File

@ -107,7 +107,7 @@ TEST_CASE("Websocket_server", "[websocket_server]")
std::string errMsg;
bool tls = false;
std::shared_ptr<Socket> socket = createSocket(tls, errMsg);
std::string host("localhost");
std::string host("127.0.0.1");
auto isCancellationRequested = []() -> bool
{
return false;
@ -141,7 +141,7 @@ TEST_CASE("Websocket_server", "[websocket_server]")
std::string errMsg;
bool tls = false;
std::shared_ptr<Socket> socket = createSocket(tls, errMsg);
std::string host("localhost");
std::string host("127.0.0.1");
auto isCancellationRequested = []() -> bool
{
return false;
@ -178,7 +178,7 @@ TEST_CASE("Websocket_server", "[websocket_server]")
std::string errMsg;
bool tls = false;
std::shared_ptr<Socket> socket = createSocket(tls, errMsg);
std::string host("localhost");
std::string host("127.0.0.1");
auto isCancellationRequested = []() -> bool
{
return false;

View File

@ -100,7 +100,7 @@ namespace
std::string url;
{
std::stringstream ss;
ss << "ws://localhost:"
ss << "ws://127.0.0.1:"
<< _port
<< "/"
<< _user;