Repository navigation
refactor(platform): own pseudo-terminals behind the host boundary - #2113
Merged
Merged
Conversation
The daemon's WebSocket serial handler tests drove the production code with `libc::openpty`/`ttyname_r`/`poll`/`read` directly, and each of the four Linux-only tests carried its own `#[cfg(target_os = "linux")]`. That is fifteen baselined host occurrences in test code, and no other crate could reuse the terminal. `platform::pty` now owns the mechanic: `PtyPair::open` allocates the pair inside the concrete per-OS tree, `slave_name` reports the device path fbuild is given as an attached port, `wait_for_master_input` polls the master side, and `read_master_exact` drains it. Holding the pair keeps the terminal live and dropping it closes both directions, which is how the deploy-preemption tests make a port disappear. Linux implements it against `openpty`; Windows and macOS report `is_supported() == false` and `open()` returns `Unsupported` (a ConPTY pipe is not a serial device path, and macOS allocates PTYs through a path this repo has not verified), so the tests ask the facade instead of selecting a host. The daemon's `libc` dev-dependency is gone with its last user. Ledger 40 -> 24 occurrences, Dylint baseline 39 -> 24; the research TSV is regenerated and `--check` passes. #1315
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continues #1315 (phase 9/9): the next capability group off the
transitional ledger is the daemon's WebSocket serial handler tests —
15 of the 40 remaining occurrences were
libc::openpty/ttyname_r/poll/readplus five
#[cfg(target_os = "linux")]gates insidecrates/fbuild-daemon/src/handlers/websockets_tests.rs.What changed
platform::ptynow owns the mechanic, with the native call in the concreteper-OS tree:
PtyPair::open()openpty+ttyname_rErr(Unsupported)slave_name()/dev/pts/Nwait_for_master_input(timeout)poll(POLLIN)read_master_exact(&mut [u8])readloop,EINTRretryis_supported()truefalseHolding the pair keeps the terminal live; dropping it closes both directions,
which is exactly what
serial_ws_preemption_reconnects_to_renumbered_portneedsin order to make the original port disappear.
The four handler tests ask
is_supported()instead of selecting a host, so thedaemon carries no
cfg(target_os …)and nolibchere. The daemon'slibcdev-dependency is removed with its last user.
Counts (a migration, not a re-baseline)
ci/platform_boundary_ledger.tsv: 40 → 24 rows (15 websockets + thedaemon
Cargo.tomllibcdependency row).dylints/enforce_platform_boundary/src/baseline.txt: 39 → 24.ci/platform_boundary_research.tsvregenerated (--write);--checkpasses.ci/test_enforce_platform_boundary.pyexplicit row count 40 → 24.Verification
soldr cargo test -p fbuild-daemon --lib serial_ws— 4 passed / 0 failed./dev/nullinstead of the real slave failsserial_ws_replies_follow_request_order(panic at the attach assertion);restored, the four are green again. So the tests really drive the new path.
soldr cargo test -p fbuild-core --lib— 452 passed / 0 failed / 2 ignored.soldr cargo test -p fbuild-daemon --lib— 332 passed / 0 failed / 3 ignored.soldr cargo clippy -p fbuild-core -p fbuild-daemon --all-targets --no-deps -- -D warnings— exit 0.soldr cargo fmt --all -- --check— exit 0.uv run --no-project python ci/enforce_platform_boundary.py --print-totals—rows=24; dylint_rows=24, exit 0.uv run --no-project python ci/platform_boundary_research.py --check— exit 0.uv run --no-project --with pyyaml python -m unittest ci.test_enforce_platform_boundary ci.test_platform_boundary_research— 30 tests, OK.#[cfg(unix)]to the test module makes the enforcerreport
new occurrence … #[cfg(unix)]and exit 1.Not in this PR
The remaining 24 rows (
fbuild-paths/executable_hash.rs7,esp_qemu.rs6,esp_qemu_runtime.rs3, emulator/tests_process 2,platformio_package_resolution2,and the
current_exe/qemu singletons) are the next units, one per run. Nozeroing of the baseline (that needs phase-8's toolchain/emulator group) and no
three-host audit table (closing pass) here.
#1315 stays open.