Skip to content

Net: Replace timing-dependent tests with condition-based waiting #5139

@matejk

Description

@matejk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions