Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Foo committed Mar 31, 2024
1 parent 7ed2fac commit cf4f668
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/runTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,8 @@ jobs:
unitTests:
strategy:
matrix:
name: [ubuntu-gcc, ubuntu-clang, windows-VS, macOS]
name: [macOS]
include:
- name: ubuntu-gcc
os: ubuntu-latest
compiler_opt: "-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"
build_system: '-G Ninja'
filter: ""
- name: ubuntu-clang
os: ubuntu-latest
compiler_opt: "-DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17"
build_system: '-G Ninja'
filter: ""
- name: windows-VS
os: windows-latest
compiler_opt: ""
build_system: ""
filter: "robustness"
- name: macOS
os: macos-latest
compiler_opt: "-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"
Expand Down
6 changes: 4 additions & 2 deletions src/src/SocketFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace MinimalSocket {
namespace {
#ifdef _WIN32
#define REBIND_OPTION SO_REUSEADDR
#else
#elif defined(__unix__) || defined(__APPLE__)
#define REBIND_OPTION SO_REUSEPORT
#endif
} // namespace
Expand Down Expand Up @@ -158,8 +158,10 @@ int isTimeoutErrorCode(int code) {
return
#ifdef _WIN32
code == WSAETIMEDOUT || code == WSAEWOULDBLOCK;
#else
#elif defined(__unix__)
code == EAGAIN || code == EWOULDBLOCK;
#elif defined(__APPLE__)
code == EAGAIN;
#endif
}

Expand Down
10 changes: 8 additions & 2 deletions tests/TestTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ TEST_CASE("Establish tcp connection non blocking", "[tcp]") {
},
[&](Barrier &br) {
br.arrive_and_wait();
TcpClient<true> client{ Address{port, family} };
TcpClient<true> client{Address{port, family}};
client.open();
REQUIRE(client.wasOpened());
client.send(request);
Expand All @@ -299,7 +299,7 @@ TEST_CASE("Receive non blocking (tcp)", "[tcp]") {
const auto family = GENERATE(AddressFamily::IP_V4, AddressFamily::IP_V6);

std::optional<tcp::TcpConnectionNonBlocking> server_side;
tcp::TcpClient<false> client_side{ Address{port, family} };
tcp::TcpClient<false> client_side{Address{port, family}};
ParallelSection::biSection(
[&](Barrier &br) {
tcp::TcpServer<true> server{port, family};
Expand All @@ -316,13 +316,19 @@ TEST_CASE("Receive non blocking (tcp)", "[tcp]") {
SECTION("client side non blocking receive") {
CHECK(client_side.receive(request.size()).empty());
server_side->send(request);
#if defined(__APPLE__)
std::this_thread::sleep_for(std::chrono::seconds{3});
#endif
auto received_request = client_side.receive(request.size());
CHECK(received_request == request);
}

SECTION("server side non blocking receive") {
CHECK(server_side->receive(request.size()).empty());
client_side.send(request);
#if defined(__APPLE__)
std::this_thread::sleep_for(std::chrono::seconds{3});
#endif
auto received_request = server_side->receive(request.size());
CHECK(received_request == request);
}
Expand Down
6 changes: 6 additions & 0 deletions tests/TestUDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ TEST_CASE("Receive from unknown non blocking", "[udp]") {

CHECK_FALSE(responder->receive(request.size()).has_value());
requester->sendTo(request, responder_address);
#if defined(__APPLE__)
std::this_thread::sleep_for(std::chrono::seconds{3});
#endif
auto received_request = responder->receive(request.size());
REQUIRE(received_request.has_value());
CHECK(received_request->received_message == request);
Expand All @@ -378,6 +381,9 @@ TEST_CASE("Receive non blocking (udp)", "[udp]") {

CHECK(responder->receive(request.size()).empty());
requester->send(request);
#if defined(__APPLE__)
std::this_thread::sleep_for(std::chrono::seconds{3});
#endif
auto received_request = responder->receive(request.size());
CHECK(received_request == request);
}

0 comments on commit cf4f668

Please sign in to comment.