Problem
Some functional tests are shown as skipped when running on macOS & BSD because test_framework/netutil.py only implemented the Linux-specific logic for checking which TCP sockets a node is listening on.
Fix
Add macOS and BSD implementations in test/functional/test_framework/netutil.py so tests can query:
- which TCP sockets a node is listening on (
get_bind_addrs(), vialsof) - a non-loopback interface address (
all_interfaces(), viaifconfig)
Then enable the previously Linux-only tests by switching to a shared POSIX platform guard.
Commands
<details> <summary><code>get_bind_addrs()</code> (<code>lsof</code> + regex)</summary>
Command used
lsof -nP -a -p <pid> -iTCP -sTCP:LISTEN -Ftn
Flags
- -D: device cache warnings
- -n: no hostname resolution
- -P: no service/port-name resolution
- -a: AND all conditions
- -p <pid>: filter by process ID
- -iTCP: TCP sockets only
- -sTCP:LISTEN: listening sockets only
- -Ftn: machine-readable output (fields: type
t, namen)
Regex parser
t(IPv[46])\nn(\*|\[.+?]|[^:]+):(\d+)
Captured groups
- group 1: IPv4 / IPv6 (used to disambiguate
*) - group 2: host (
*,[::1],127.0.0.1, ...) - group 3: port
</details>
<details> <summary><code>all_interfaces()</code> (<code>ifconfig</code> + regex)</summary>
Command used
ifconfig -au
Regex parsing
Interface blocks:
(?m)^(?P<iface>\S+):(?P<block>[^\n]*(?:\n[ \t]+[^\n]*)*)
IPv4 extraction within each block:
inet (\S+)
</details>
Notes
The only remaining platform skips on macOS are the USDT/BPF tracing tests (interface_usdt_*.py).