refator test
This commit is contained in:
@@ -98,23 +98,25 @@ TEST(packet_comm_common_test, idle_socket_considered_alive) {
|
||||
client_sock.connect(
|
||||
tcp::endpoint{boost::asio::ip::address_v4::loopback(), port});
|
||||
|
||||
for (int attempt = 0; attempt < 50 and not accepted; ++attempt) {
|
||||
for (std::uint8_t attempt = 0U; attempt < 50U and not accepted; ++attempt) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{2});
|
||||
}
|
||||
ASSERT_TRUE(accepted);
|
||||
|
||||
EXPECT_TRUE(comm::is_socket_still_alive(client_sock));
|
||||
|
||||
boost::system::error_code ec;
|
||||
client_sock.shutdown(tcp::socket::shutdown_both, ec);
|
||||
client_sock.close(ec);
|
||||
boost::system::error_code err;
|
||||
[[maybe_unused]] auto res =
|
||||
client_sock.shutdown(tcp::socket::shutdown_both, err);
|
||||
[[maybe_unused]] auto res2 = client_sock.close(err);
|
||||
|
||||
if (server_sock and server_sock->is_open()) {
|
||||
server_sock->shutdown(tcp::socket::shutdown_both, ec);
|
||||
server_sock->close(ec);
|
||||
[[maybe_unused]] auto res3 =
|
||||
server_sock->shutdown(tcp::socket::shutdown_both, err);
|
||||
[[maybe_unused]] auto res4 = server_sock->close(err);
|
||||
}
|
||||
|
||||
acceptor.close(ec);
|
||||
[[maybe_unused]] auto res4 = acceptor.close(err);
|
||||
io_ctx.stop();
|
||||
if (io_thread.joinable()) {
|
||||
io_thread.join();
|
||||
@@ -147,23 +149,25 @@ TEST(packet_comm_common_test, closed_socket_is_not_reused) {
|
||||
client_sock.connect(
|
||||
tcp::endpoint{boost::asio::ip::address_v4::loopback(), port});
|
||||
|
||||
for (int attempt = 0; attempt < 50 and not accepted; ++attempt) {
|
||||
for (std::uint8_t attempt = 0U; attempt < 50U and not accepted; ++attempt) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{2});
|
||||
}
|
||||
ASSERT_TRUE(accepted);
|
||||
|
||||
boost::system::error_code ec;
|
||||
client_sock.shutdown(tcp::socket::shutdown_both, ec);
|
||||
client_sock.close(ec);
|
||||
boost::system::error_code err;
|
||||
[[maybe_unused]] auto res =
|
||||
client_sock.shutdown(tcp::socket::shutdown_both, err);
|
||||
[[maybe_unused]] auto res2 = client_sock.close(err);
|
||||
|
||||
EXPECT_FALSE(comm::is_socket_still_alive(client_sock));
|
||||
|
||||
if (server_sock and server_sock->is_open()) {
|
||||
server_sock->shutdown(tcp::socket::shutdown_both, ec);
|
||||
server_sock->close(ec);
|
||||
[[maybe_unused]] auto res3 =
|
||||
server_sock->shutdown(tcp::socket::shutdown_both, err);
|
||||
[[maybe_unused]] auto res4 = server_sock->close(err);
|
||||
}
|
||||
|
||||
acceptor.close(ec);
|
||||
[[maybe_unused]] auto res5 = acceptor.close(err);
|
||||
io_ctx.stop();
|
||||
if (io_thread.joinable()) {
|
||||
io_thread.join();
|
||||
|
Reference in New Issue
Block a user