diff --git a/tests/s25Main/network/TestServer.cpp b/tests/s25Main/network/TestServer.cpp index 3b63b4fcb..5ab78a9e8 100644 --- a/tests/s25Main/network/TestServer.cpp +++ b/tests/s25Main/network/TestServer.cpp @@ -41,7 +41,6 @@ bool TestServer::run(bool waitForConnection) { if(set.InSet(connections[id].so)) { - // nachricht empfangen if(connections[id].recvQueue.recv(connections[id].so) < 0) connections.erase(connections.begin() + id); else @@ -49,7 +48,9 @@ bool TestServer::run(bool waitForConnection) msgReceived = true; ++id; } - } else + } else if(!connections[id].so.isValid()) + connections.erase(connections.begin() + id); // LCOV_EXCL_LINE + else ++id; } } while(msgReceived); diff --git a/tests/s25Main/network/main.cpp b/tests/s25Main/network/main.cpp index 811ecf9c5..eb16f159c 100644 --- a/tests/s25Main/network/main.cpp +++ b/tests/s25Main/network/main.cpp @@ -5,6 +5,7 @@ #define BOOST_TEST_MODULE RTTR_Network #include "TestServer.h" +#include "helpers/CIUtils.h" #include #include #include @@ -28,9 +29,7 @@ BOOST_AUTO_TEST_CASE(TestServer_Works) auto runServer = [&server]() { const auto result = server.run(); for(int i = 0; i < 5; i++) - { BOOST_TEST(server.run() == result); - } return result; }; BOOST_TEST(!runServer()); @@ -54,5 +53,13 @@ BOOST_AUTO_TEST_CASE(TestServer_Works) BOOST_TEST(runServer()); sock.Close(); BOOST_TEST(runServer()); - BOOST_TEST_REQUIRE(server.connections.size() == 1u); + if(rttr::isRunningOnCI()) // On CI retry to avoid flakes + { + for(int i = 0; i < 5; i++) + { + if(server.connections.size() == 2u) + BOOST_TEST(runServer()); // LCOV_EXCL_LINE + } + } + BOOST_TEST(server.connections.size() == 1u); }