99b86336
test: the taken-port leg counts listeners through the oracle, so the web group runs on macOS
a73x 2026-09-04 13:23
Commit message
test/e2e_06_web.sh
| Old | New | ||
|---|---|---|---|
| @@ -629,15 +629,12 @@ grep -q "already running" "$OUT.dwtaken" || { | |||
| 629 | grep -q "serving" "$OUT.dwtaken" && { | 629 | grep -q "serving" "$OUT.dwtaken" && { |
| 630 | echo "e2e FAIL: host wall: the second hub announced itself on a taken port:" | 630 | echo "e2e FAIL: host wall: the second hub announced itself on a taken port:" |
| 631 | cat "$OUT.dwtaken"; exit 1; } | 631 | cat "$OUT.dwtaken"; exit 1; } |
| 632 | # Asked of the OS, not of either hub: exactly one socket LISTENs there. | 632 | # Asked of the OS, not of either hub, through the oracle's tcp_listeners |
| 633 | # /proc/net/tcp rather than ss or lsof, for e2e_01_boot.sh's reason — always | 633 | # (the Linux arm reads /proc/net/tcp, the Darwin arm asks lsof): exactly one |
| 634 | # present, no privileges — with 0A the LISTEN state and 0100007F the | 634 | # socket LISTENs there. |
| 635 | # little-endian hex the file spells 127.0.0.1 in. | 635 | LISTENERS=$(tcp_listeners "$WPORT4") |
| 636 | WHEX=$(printf '0100007F:%04X' "$WPORT4") | ||
| 637 | LISTENERS=$(awk -v a="$WHEX" '$2 == a && $4 == "0A" { n++ } END { print n+0 }' /proc/net/tcp) | ||
| 638 | [ "$LISTENERS" -eq 1 ] || { | 636 | [ "$LISTENERS" -eq 1 ] || { |
| 639 | echo "e2e FAIL: host wall: $LISTENERS listeners on $WPORT4, want 1:" | 637 | echo "e2e FAIL: host wall: $LISTENERS listeners on $WPORT4, want 1"; exit 1; } |
| 640 | grep -i "$WHEX" /proc/net/tcp || true; exit 1; } | ||
| 641 | # ...and the survivor is the first hub, still serving the wall it built: | 638 | # ...and the survivor is the first hub, still serving the wall it built: |
| 642 | # the refusal happens in the newcomer, and the running hub never hears it. | 639 | # the refusal happens in the newcomer, and the running hub never hears it. |
| 643 | [ -n "$(curl -s "$DWORIG/tiles")" ] || { | 640 | [ -n "$(curl -s "$DWORIG/tiles")" ] || { |
test/os_oracle.sh
| Old | New | ||
|---|---|---|---|
| @@ -168,6 +168,15 @@ Darwin) | |||
| 168 | grep -qxF "$_ua" | 168 | grep -qxF "$_ua" |
| 169 | } | 169 | } |
| 170 | udp_table() { lsof -iUDP -P -n 2>/dev/null; } | 170 | udp_table() { lsof -iUDP -P -n 2>/dev/null; } |
| 171 | # tcp_listeners PORT — how many sockets LISTEN on 127.0.0.1:PORT, as a | ||
| 172 | # bare decimal. Asked with lsof's own state filter so a connected client | ||
| 173 | # on the same port is not counted, and matched on the local address | ||
| 174 | # for udp_local_bound's reason. The web group wants exactly one, because | ||
| 175 | # SO_REUSEPORT once let two hubs bind the same port. | ||
| 176 | tcp_listeners() { | ||
| 177 | lsof -iTCP@127.0.0.1:"$1" -sTCP:LISTEN -P -n -Fn 2>/dev/null | | ||
| 178 | sed -n 's/^n//p' | grep -cx "127.0.0.1:$1" | ||
| 179 | } | ||
| 171 | file_mode() { stat -f %Lp "$1"; } | 180 | file_mode() { stat -f %Lp "$1"; } |
| 172 | file_size() { stat -f %z "$1"; } | 181 | file_size() { stat -f %z "$1"; } |
| 173 | sha256_of() { shasum -a 256 "$1" | cut -d' ' -f1; } | 182 | sha256_of() { shasum -a 256 "$1" | cut -d' ' -f1; } |
| @@ -272,6 +281,13 @@ print "$r\n";' "$1" | |||
| 272 | # listener. | 281 | # listener. |
| 273 | udp_local_bound() { awk -v h="$1" '$2==h{f=1} END{exit !f}' /proc/net/udp; } | 282 | udp_local_bound() { awk -v h="$1" '$2==h{f=1} END{exit !f}' /proc/net/udp; } |
| 274 | udp_table() { cat /proc/net/udp 2>/dev/null; } | 283 | udp_table() { cat /proc/net/udp 2>/dev/null; } |
| 284 | # 0A is LISTEN in /proc/net/tcp, and 0100007F the little-endian hex the | ||
| 285 | # file spells 127.0.0.1 in. /proc rather than ss or lsof, for the udp | ||
| 286 | # arm's reason: always present, no privileges. | ||
| 287 | tcp_listeners() { | ||
| 288 | awk -v a="$(printf '0100007F:%04X' "$1")" \ | ||
| 289 | '$2 == a && $4 == "0A" { n++ } END { print n+0 }' /proc/net/tcp | ||
| 290 | } | ||
| 275 | file_mode() { stat -c %a "$1"; } | 291 | file_mode() { stat -c %a "$1"; } |
| 276 | file_size() { stat -c %s "$1"; } | 292 | file_size() { stat -c %s "$1"; } |
| 277 | sha256_of() { sha256sum "$1" | cut -d' ' -f1; } | 293 | sha256_of() { sha256sum "$1" | cut -d' ' -f1; } |