Commit 97d588c4
97d588c4ef1fMerged
Ori Pekelman <[email protected]> · 5 months ago · 4 files · ~4 modified
Description
sp_net: platform-guard for Windows; cross-platform test; EINTR/SIGPIPE/port robustness
Address review feedback on the sp_net extraction.
CI blockers (matz):
- Windows: wrap the TU in #if defined(_WIN32) -> thin error-sentinel stubs, #else -> the POSIX implementation. <poll.h>/fork/sigaction/BSD sockets don't exist under MinGW; the stubs keep libspinel_rt.a building everywhere with sp_net simply absent on Windows (mirrors sp_runtime.h's per-platform fiber backend).
- macOS test: the TCP-loopback smoke wasn't deterministic off Linux. Drop it from test/sp_net_basic.rb; keep shell_capture + getpid, which are deterministic on every POSIX target. The Makefile filters the test out on Windows (where sp_net is stubbed). The socket/poll/process surface is exercised by the POSIX consumer suites (tep).
Robustness (gemini-code-assist):
- sp_net_poll_run: check sp_net_term_flag and return -1 on EINTR if set, so a shutdown signal during poll() isn't retried into an indefinite block.
- sp_net_recv_some / sp_net_recv_all: retry on EINTR (was treated as EOF/error) while honoring sp_net_term_flag for cooperative shutdown.
- sp_net_connect: ignore SIGPIPE (a client that never listens still needs it, or a write to a closed upstream kills the process).
- sp_net_listen / sp_net_connect: validate port is in [0, 65535].
Verified: POSIX + (-D_WIN32) stub branches both compile; trimmed test passes on linux-aarch64.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 97d588c4ef1f
- Parent
- adee2ef2d900
MakefilemodifiedView file
@@ -401,6 +401,12 @@
401401
ifeq ($(SPINEL_INT_OVERFLOW),promote)402402
TESTS := $(filter-out test/int_overflow_raises.rb,$(TESTS))403403
endif404+
# sp_net is POSIX-only; on Windows the TU compiles to stubs, so the405+
# sp_net smoke's output diverges. Skip it there (the POSIX surface is406+
# exercised by consumer suites on POSIX targets).407+
ifeq ($(OS),Windows_NT)408+
TESTS := $(filter-out test/sp_net_basic.rb,$(TESTS))409+
endif404410
TEST_TARGETS := $(patsubst test/%.rb,build/test-results/%.ok,$(TESTS))405411
406412
# `make test` is incremental via mtime tracking on .ok files;lib/sp_net.cmodifiedView file
Loading diff…
test/sp_net_basic.rbmodifiedView file
Loading diff…
test/sp_net_basic.rb.expectedmodifiedView file
Loading diff…