diff --git a/test/perfdata-perfdatatargetfixture.hpp b/test/perfdata-perfdatatargetfixture.hpp index bac1c504d..8c2a381bc 100644 --- a/test/perfdata-perfdatatargetfixture.hpp +++ b/test/perfdata-perfdatatargetfixture.hpp @@ -71,11 +71,20 @@ public: BOOST_REQUIRE(stream->next_layer().IsVerifyOK()); } - void Shutdown() + void Shutdown(bool wait = false) { BOOST_REQUIRE(std::holds_alternative::Ptr>(m_Stream)); auto& stream = std::get::Ptr>(m_Stream); try { + if (wait) { + std::array buf{}; + boost::asio::mutable_buffer readBuf (buf.data(), buf.size()); + boost::system::error_code ec; + + do { + stream->read_some(readBuf, ec); + } while (!ec); + } stream->next_layer().shutdown(); } catch (const std::exception& ex) { if (const auto* se = dynamic_cast(&ex); diff --git a/test/perfdata-perfdatawriterconnection.cpp b/test/perfdata-perfdatawriterconnection.cpp index 16ed299a9..0f2435198 100644 --- a/test/perfdata-perfdatawriterconnection.cpp +++ b/test/perfdata-perfdatawriterconnection.cpp @@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(stuck_reading_response) requestReadPromise.set_value(); // Do not send a response but react to the shutdown to be polite. shutdownPromise.get_future().get(); - Shutdown(); + Shutdown(true); }}; TestThread timeoutThread{[&]() { @@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(http_send_retry) SendResponse(); - Shutdown(); + Shutdown(true); }}; boost::beast::http::request request{boost::beast::http::verb::post, "foo", 10};