Problem
Some functional tests are shown as skipped when running on macOS because test_framework/netutil.py only implemented the Linux-specific logic for checking which TCP sockets a node is listening on.
Fix
Add macOS 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 platform guard.
Commands
Command used
0lsof -nP -a -p <pid> -iTCP -sTCP:LISTEN -Ftn
Flags
- -n: no hostname resolution
- -P: no service/port-name resolution
- -a: AND all conditions
- -p : filter by process ID
- -iTCP: TCP sockets only
- -sTCP:LISTEN: listening sockets only
- -Ftn: machine-readable output (fields: type t, name n)
Regex parser
0t(IPv[46])\nn(\*|\[.+?]|[^:]+):(\d+)
Captured groups
- group 1: IPv4 / IPv6 (used to disambiguate *)
- group 2: host (*, [::1], 127.0.0.1, …)
- group 3: port
Command used
0ifconfig -au
Regex parsing
Interface blocks:
0(?m)^(?P<iface>\S+):(?P<block>[^\n]*(?:\n[ \t]+[^\n]*)*)
IPv4 extraction within each block:
0inet (\S+)
Notes
The only remaining platform skips on macOS are the USDT/BPF tracing tests (interface_usdt_*.py).