Local-only regression patterns for hostname resolution in socket tests
Hostname resolution is easy to over-test with flaky internet dependencies. In this repo, the safer pattern is to separate the raw IPv4 parser from the public resolver API and keep all end-to-end coverage on loopback.
Keep l_inet_addr("localhost") == 0 as a regression test for the dotted-quad parser. Put hostname-success assertions on l_resolve(...), then feed its output into socket helpers.
For int l_resolve(const char *hostname, char *ip_out), cover:
"127.0.0.1" stays unchanged)"localhost")"256.0.0.1"Open a local listener inside the test, resolve "localhost" once, then exercise the integration twice:
l_resolve("localhost", ip)"127.0.0.1"That proves hostname resolution works without depending on /etc/hosts contents beyond standard loopback setup, public DNS, or outbound internet access.
If the approved surface is l_resolve(...), treat that as the contract. Unless the implementation explicitly promises hostname-aware l_socket_connect/l_socket_sendto, use resolved IPv4 strings for integration tests rather than asserting direct "localhost" success.
Derive the starting port from l_getpid() and scan a bounded high-port range until bind succeeds. This avoids hard-coded port collisions across parallel runs while staying deterministic enough for CI.
If test/test.c already has open_loopback_listener(), keep extending that helper instead of adding another ad hoc port chooser. One helper keeps hostname tests consistent across Windows, Linux, ARM, and AArch64.
After the loopback connect/send succeeds, accept or receive the packet and exchange a tiny payload ("ok" is enough). That catches regressions where resolution works but the integration path is still broken.
l_inet_addr to resolve hostnames — that conflates the string parser with l_resolve.