Summary
Follow-up to #5137 which introduced waitForCondition() for Foundation tests.
The Net testsuite has similar patterns that could benefit from waitForCondition to eliminate flaky timing-dependent tests.
High Priority (Unbounded Loops)
| File |
Line |
Pattern |
PollSetTest.cpp |
451 |
while (!poller.isRunning()) Thread::sleep(100); |
UDPServerTest.cpp |
122-134 |
do { Thread::sleep(10); } while (count < i); |
Medium Priority (Fixed Sleeps + Assertions)
| File |
Count |
Notes |
DatagramSocketTest.cpp |
1 |
Sleep before assertTrue(ss.available() == 5) |
WebSocketTest.cpp |
4 |
Sleeps waiting for server start |
SyslogTest.cpp |
6 |
Sleeps waiting for syslog processing |
TCPServerTest.cpp |
10 |
Sleeps in server tests |
Scope
Total: ~49 Thread::sleep calls across 13 files, of which 2 are critical unbounded loops and ~8-10 are good candidates for condition-based waiting.
Pattern to Apply
// Before (unbounded, can hang forever):
while (condition) Thread::sleep(50);
// After (bounded, fails cleanly if condition never met):
assertTrue(waitForCondition([&]{ return condition; }, 5000));
References
Summary
Follow-up to #5137 which introduced
waitForCondition()for Foundation tests.The Net testsuite has similar patterns that could benefit from
waitForConditionto eliminate flaky timing-dependent tests.High Priority (Unbounded Loops)
PollSetTest.cppwhile (!poller.isRunning()) Thread::sleep(100);UDPServerTest.cppdo { Thread::sleep(10); } while (count < i);Medium Priority (Fixed Sleeps + Assertions)
DatagramSocketTest.cppassertTrue(ss.available() == 5)WebSocketTest.cppSyslogTest.cppTCPServerTest.cppScope
Total: ~49
Thread::sleepcalls across 13 files, of which 2 are critical unbounded loops and ~8-10 are good candidates for condition-based waiting.Pattern to Apply
References