Repository navigation
serve: fix test helpers that miss the Cargo binary, leak children and corrupt UTF-8 - #714
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: The changed helpers retain child ownership during startup failures and preserve SSE bytes across reads.
Checked
Duplicates: 9 introduced or relocated functions/constants checked; no new duplicate owner. Dryer reported 0 pairs.
Complexity: crapper flagged no changed function. The extracted helpers retain their existing control flow.
Silent failure: 5 parsing/default sites followed. An absent request body means empty input; bad status or startup parsing and missing required stderr lines fail the test. Raw response heads remain available to the key assertions. Truncated heads, cut frames and invalid SSE UTF-8 panic by name.
Tests: static mutation review of all four added or moved tests. Replacing the Cargo binary path at serve.rs:1261 with the old fixed path fails startup under a custom target directory. Removing argv redaction at api.rs:2061 fails the moved key assertion. Delaying guard creation at serve.rs:1275 until after parsing fails the child-reaping assertion. Restoring per-read lossy decoding at slots/mod.rs:702 fails content equality. Removing the EOF assertions at slots/mod.rs:724, or using lossy frame decoding at line 711, fails the malformed-stream assertion.
Gates: no threshold or tolerance moved; the relocated key test retains its assertions and adds response-head coverage.
Escape catalog: C1–C4 do not match. The cleanup test inspects its recorded child PID.
Adversarial checks: startup failure before address parsing, splits inside UTF-8 and delimiters, malformed EOF, and several frames in one read are covered. The stream consumer also requires both final chunks. No engine hot path changes.
Notes
Builds and tests were not run in this read-only review. The PR includes CPU FAIL-first and passing-run excerpts; it contains no GPU gate evidence.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
serve 시험 도우미의 세 가지 결함(Cargo 대상 경로 무시, 시작 실패 시 자식 프로세스 방치, SSE UTF-8 깨짐)을 고치고 각각 회귀 시험을 추가합니다.
Part of #565. Tracked in #699.
What and why
Three helpers in the
bloomery-servetests can mislead a run.a_key_never_reaches_what_the_process_prints_or_serves) started the server from a fixedtarget/debug/bloomery-servepath. The binary is not there wheneverCARGO_TARGET_DIRis set, so the test stops on a missing file. It came in with 98f23be.from_utf8_lossy, so a multi-byte character split across two reads became replacement characters in the observed chunk. It came in with 3c5a133.This PR fixes all three, and one case of the same kind: the reader also accepted a stream that ended inside the HTTP head, inside an SSE frame, or with invalid UTF-8.
serveintegration tests and starts the server withCARGO_BIN_EXE_bloomery-serve.BinServeandspawn_bininsrc/testserve.rsare removed, and so is the old test insrc/api.rs. The test keeps its name and its assertions. It now also checks the full response head, not only the body, for the server key and the key the client sent, soReplykeeps the raw head.spawn_mocktakes a newspawn_commandhelper that wraps the child in the existingReapedguard right after the spawn, so a panic while reading the startup line or parsing the address kills and reaps the child.read_streamkeeps raw bytes and checks UTF-8 only on a complete SSE frame. It now panics by name when the stream closes before the HTTP head ends, in the middle of a frame, or on invalid UTF-8. Looking at the borrowed frame also removes one string copy per non-empty frame.The change is test code only. There is no new option, dependency, public API, GPU path or unsafe code.
Release notes: internal: the serve tests use the Cargo binary path, reap children after a bad start and keep split UTF-8 intact.
Code shape
spawn_command,read_chunksandcall_headersare extracted from or extend the existing test helpers, and the duplicateBinServeandspawn_binare removed.BinServe,spawn_binand the in-crate copy of the API-key test are removed.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.rustfmton the changed files andgit diff --checkare clean, and the duplicate scan found no candidate. Clippy has not been run on this head.Duplication found or removed (
path:line), or "none": removed theBinServeandspawn_bincopy incrates/serve/src/testserve.rs, which duplicatedspawn_mockincrates/serve/tests/serve.rs.What I ran
All commands ran from the workspace root with
CARGO_BUILD_JOBS=4,RUSTFLAGS='-C target-cpu=native'andCARGO_TARGET_DIR="$PWD/target/servetests". The tests use no GPU and no model.Environment: Linux x86_64 CPU,
rustc 1.100.0-nightly (e457a7b0d 2026-08-27).FAIL-first: I ran the new tests on the old helper behavior (the same test additions, with the old code and a mechanical extraction so they compile), then on the fix. Log excerpt from the old behavior, one block per defect:
The split case shows
가é🦀read back with its first character replaced by replacement characters. The stream-chunks run also reports the three malformed inputs (a cut head, a cut frame and invalid UTF-8) as accepted.On the fix, the four tests run together and the older tests that use the same helpers run with
--ignored:The older tests are
hw_engine_error_is_500_then_503_then_exit,hw_props_engine_objectandslots::hw_drafted_passes_interleave_across_slots.The last commit adds the response-head check to the API-key test and changes only test data and assertions in
common. I ran only that test on it, on a Linux ARM CPU machine with its ownCARGO_TARGET_DIR, which also checks that the server binary sits in that directory:The process guard, the stream reader and the two other regression tests are unchanged since the run above, so I did not repeat that run on the last commit.
Not run: clippy,
t0and the full workspace test suite. No kernel, launch or product path changed, so I took no timing.Reproduction
On the old helpers the first command stops on the missing binary, the unreaped children, the split at byte 63 and the three accepted inputs. On the fix the first command runs four tests and the second runs three.
What I ran into
This does not block the PR.
a_failed_startup_reaps_its_childchecks/proc/<pid>, so it is compiled only on Linux.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.