Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit 549cdf2

Browse files
authored
test: avoid infinite loop when IPV6 is unsupported (yhirose#1054)
1 parent 3c52238 commit 549cdf2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/test.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,15 @@ TEST(RedirectFromPageWithContentIP6, Redirect) {
971971

972972
auto th = std::thread([&]() { svr.listen("::1", 1234); });
973973

974-
while (!svr.is_running()) {
974+
// When IPV6 support isn't available svr.listen("::1", 1234) never
975+
// actually starts anything, so the condition !svr.is_running() will
976+
// always remain true, and the loop never stops.
977+
// This basically counts how many milliseconds have passed since the
978+
// call to svr.listen(), and if after 5 seconds nothing started yet
979+
// aborts the test.
980+
for (unsigned int milliseconds = 0; !svr.is_running(); milliseconds++) {
975981
std::this_thread::sleep_for(std::chrono::milliseconds(1));
982+
ASSERT_LT(milliseconds, 5000U);
976983
}
977984

978985
// Give GET time to get a few messages.

0 commit comments

Comments
 (0)