Skip to content

Commit 7ee3386

Browse files
Fix PerfdataWriterConnection test-cases on parallel build
1 parent aab0b64 commit 7ee3386

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

test/perfdata-perfdatatargetfixture.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,24 @@ class PerfdataWriterTargetFixture
3939
explicit PerfdataWriterTargetFixture(AsioTlsOrTcpStream stream)
4040
: m_Stream(std::move(stream)),
4141
m_Acceptor(
42-
IoEngine::Get().GetIoContext(),
43-
boost::asio::ip::tcp::endpoint{boost::asio::ip::address_v4::loopback(), 0}
42+
IoEngine::Get().GetIoContext()
4443
)
4544
{
45+
boost::asio::ip::tcp::endpoint ep{boost::asio::ip::address_v4::loopback(), 0};
46+
m_Acceptor.open(ep.protocol());
47+
m_Acceptor.bind(ep);
4648
}
4749

4850
unsigned short GetPort() { return m_Acceptor.local_endpoint().port(); }
4951

52+
void Listen()
53+
{
54+
m_Acceptor.listen();
55+
}
56+
5057
void Accept()
5158
{
59+
Listen();
5260
BOOST_REQUIRE_NO_THROW(
5361
std::visit([&](auto& stream) { return m_Acceptor.accept(stream->lowest_layer()); }, m_Stream)
5462
);

test/perfdata-perfdatawriterconnection.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,9 @@ BOOST_AUTO_TEST_CASE(finish_during_timeout)
130130
*/
131131
BOOST_AUTO_TEST_CASE(stuck_in_handshake)
132132
{
133-
TestThread mockTargetThread{[&]() { Accept(); }};
134-
135133
std::promise<void> p;
136134
TestThread timeoutThread{[&]() {
135+
Accept();
137136
auto f = p.get_future();
138137
GetConnection().CancelAfterTimeout(f, 50ms);
139138
BOOST_REQUIRE(f.wait_for(0ms) == std::future_status::timeout);
@@ -144,7 +143,6 @@ BOOST_AUTO_TEST_CASE(stuck_in_handshake)
144143
);
145144

146145
REQUIRE_JOINS_WITHIN(timeoutThread, 1s);
147-
REQUIRE_JOINS_WITHIN(mockTargetThread, 1s);
148146
}
149147

150148
/* When the disconnect timeout runs out while sending something to a slow or blocking server, we

0 commit comments

Comments
 (0)