From 96b3f50b1b54849f463cfc7b12ee092618a72a79 Mon Sep 17 00:00:00 2001 From: hja Date: Sun, 15 Nov 2026 20:03:49 +0000 Subject: [PATCH 1/2] ci: speed up macOS job --- .github/workflows/build.yml | 7 +++--- tests/case-23-multi-address-hostname.bash | 27 ++++++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fae3221f..9460e706 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: install dependencies - run: brew install pkg-config libtool autoconf automake groff + run: brew install libtool autoconf automake - name: configure run: LSOF_INCLUDE=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include ./Configure -n darwin - name: make @@ -42,10 +42,9 @@ jobs: run: | git clean -fdx . autoreconf -vif - ./configure + ./configure --disable-manpages make DESTDIR=$PWD/prefix make install - make check - name: dist build and test run: | make dist @@ -53,7 +52,7 @@ jobs: cd temp tar xvf ../lsof-*.tar.gz cd lsof-* - ./configure + ./configure --disable-manpages make DESTDIR=$PWD/prefix make install make check diff --git a/tests/case-23-multi-address-hostname.bash b/tests/case-23-multi-address-hostname.bash index a0b8a875..d99605fc 100755 --- a/tests/case-23-multi-address-hostname.bash +++ b/tests/case-23-multi-address-hostname.bash @@ -13,19 +13,30 @@ if ! command -v python3 >/dev/null 2>&1; then fi host=$(hostname) +# Resolving a .local host name through mDNS can block for a long time on some +# machines, so cap the lookup and treat a timeout as "no addresses". naddr=$(python3 - "$host" <<'PY' +import os import socket import sys +import threading host = sys.argv[1] -count = 0 -for family in (socket.AF_INET, socket.AF_INET6): - try: - infos = socket.getaddrinfo(host, None, family, socket.SOCK_STREAM) - except OSError: - continue - count = max(count, len({info[4][0] for info in infos})) -print(count) +count = [0] + +def resolve(): + for family in (socket.AF_INET, socket.AF_INET6): + try: + infos = socket.getaddrinfo(host, None, family, socket.SOCK_STREAM) + except OSError: + continue + count[0] = max(count[0], len({info[4][0] for info in infos})) + +resolver = threading.Thread(target=resolve, daemon=True) +resolver.start() +resolver.join(5) +print(count[0], flush=True) +os._exit(0) PY ) From f3dbfc4174ea3c80a5f1f0950ab4cc3e9e11c44d Mon Sep 17 00:00:00 2001 From: hja Date: Mon, 16 Nov 2026 20:47:33 +0000 Subject: [PATCH 2/2] tests: handle hostname lookup and lsof timeouts explicitly Skip on hostname lookup timeout without using partial results. Bound lsof execution to 15 seconds and fail if it times out. --- tests/case-23-multi-address-hostname.bash | 33 +++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/case-23-multi-address-hostname.bash b/tests/case-23-multi-address-hostname.bash index d99605fc..768d0f8a 100755 --- a/tests/case-23-multi-address-hostname.bash +++ b/tests/case-23-multi-address-hostname.bash @@ -14,7 +14,8 @@ fi host=$(hostname) # Resolving a .local host name through mDNS can block for a long time on some -# machines, so cap the lookup and treat a timeout as "no addresses". +# machines. Five seconds is a pragmatic prerequisite lookup limit on all +# platforms; a timeout skips the test rather than using partial results. naddr=$(python3 - "$host" <<'PY' import os import socket @@ -35,11 +36,19 @@ def resolve(): resolver = threading.Thread(target=resolve, daemon=True) resolver.start() resolver.join(5) +if resolver.is_alive(): + print("timeout", flush=True) + os._exit(0) print(count[0], flush=True) os._exit(0) PY ) +if [ "$naddr" = timeout ]; then + echo "SKIP: hostname resolution timed out after 5 seconds" >> "$report" + exit 77 +fi + if [ "${naddr:-0}" -lt 2 ]; then echo "SKIP: $host resolves to fewer than two addresses in one family" \ >> "$report" @@ -48,7 +57,27 @@ fi { echo "host name: $host ($naddr addresses in one address family)" - $lsof -a -i@"$host" -p $$ >/dev/null 2>&1 + # Bound lsof's own lookup as well. Once the prerequisite succeeds, a hang + # is a test failure. subprocess.run kills and reaps the child on timeout. + python3 - "$lsof" "$host" "$$" <<'PY' +import subprocess +import sys + +try: + result = subprocess.run( + [sys.argv[1], "-a", "-i@" + sys.argv[2], "-p", sys.argv[3]], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + timeout=15, + ) +except subprocess.TimeoutExpired: + print("FAIL: lsof timed out after 15 seconds", flush=True) + sys.exit(124) + +# Preserve signal failures rather than mapping a negative return code to a +# shell status that could be mistaken for success or no matching files. +sys.exit(result.returncode if result.returncode >= 0 else 128 - result.returncode) +PY status=$? case $status in 0|1)