Skip to content

Commit 2dc9bb5

Browse files
committed
Fix socket tests for successful completion on Windows
1 parent 590162d commit 2dc9bb5

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

src/comm/tcp_server.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ void TCPServer::init()
7070
throw std::system_error(std::error_code(errno, std::generic_category()), "Failed to create socket endpoint");
7171
}
7272
int flag = 1;
73+
#ifndef _WIN32
7374
ur_setsockopt(listen_fd_, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(int));
75+
#endif
7476
ur_setsockopt(listen_fd_, SOL_SOCKET, SO_KEEPALIVE, &flag, sizeof(int));
7577

7678
URCL_LOG_DEBUG("Created socket with FD %d", (int)listen_fd_);

tests/test_pipeline.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class PipelineTest : public ::testing::Test
6060
pipeline_->init();
6161
}
6262

63-
void Teardown()
63+
void teardown()
6464
{
6565
// Clean up
6666
pipeline_->stop();
@@ -247,7 +247,7 @@ TEST_F(PipelineTest, connect_non_connected_robot)
247247
auto end = std::chrono::system_clock::now();
248248
auto elapsed = end - start;
249249
// This is only a rough estimate, obviously
250-
EXPECT_LT(elapsed, std::chrono::milliseconds(1500));
250+
EXPECT_LT(elapsed, std::chrono::milliseconds(7500));
251251
}
252252

253253
int main(int argc, char* argv[])

tests/test_producer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ProducerTest : public ::testing::Test
4949
server_->start();
5050
}
5151

52-
void Teardown()
52+
void teardown()
5353
{
5454
// Clean up
5555
server_.reset();
@@ -133,7 +133,7 @@ TEST_F(ProducerTest, connect_non_connected_robot)
133133
auto end = std::chrono::system_clock::now();
134134
auto elapsed = end - start;
135135
// This is only a rough estimate, obviously
136-
EXPECT_LT(elapsed, std::chrono::milliseconds(1500));
136+
EXPECT_LT(elapsed, std::chrono::milliseconds(7500));
137137
}
138138

139139
int main(int argc, char* argv[])

tests/test_stream.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class StreamTest : public ::testing::Test
5151
server_->start();
5252
}
5353

54-
void Teardown()
54+
void teardown()
5555
{
5656
// Clean up
5757
server_.reset();
@@ -329,7 +329,7 @@ TEST_F(StreamTest, connect_non_connected_robot)
329329
auto end = std::chrono::system_clock::now();
330330
auto elapsed = end - start;
331331
// This is only a rough estimate, obviously
332-
EXPECT_LT(elapsed, std::chrono::milliseconds(1500));
332+
EXPECT_LT(elapsed, std::chrono::milliseconds(7500));
333333
}
334334

335335
int main(int argc, char* argv[])

tests/test_tcp_socket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ TEST_F(TCPSocketTest, connect_non_running_robot)
351351
auto end = std::chrono::system_clock::now();
352352
auto elapsed = end - start;
353353
// This is only a rough estimate, obviously
354-
EXPECT_LT(elapsed, std::chrono::milliseconds(1500));
354+
EXPECT_LT(elapsed, std::chrono::milliseconds(7500));
355355
}
356356

357357
TEST_F(TCPSocketTest, test_deprecated_reconnection_time_interface)
@@ -374,7 +374,7 @@ TEST_F(TCPSocketTest, test_read_on_socket_abruptly_closed)
374374
server_->write(client_fd_, data, len, written);
375375

376376
// Simulate socket failure
377-
close(client_->getSocketFD());
377+
ur_close(client_->getSocketFD());
378378

379379
char characters;
380380
size_t read_chars = 0;

0 commit comments

Comments
 (0)