Skip to content

Fix flaky desktop server tests - #820

Merged
jserv merged 1 commit into
sysprog21:mainfrom
ColtenOuO:fix-desktop-etxtbsy
Nov 23, 2026
Merged

jserv merged 1 commit into
sysprog21:mainfrom
ColtenOuO:fix-desktop-etxtbsy

Conversation

@ColtenOuO

@ColtenOuO ColtenOuO commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The two desktop server tests that start a stand-in server script ran in parallel, and a spawn on one test's thread could fork while the other test's script was still open for writing. The forked child holds that descriptor until it execs, so starting the script failed with Text file busy (os error 26) and made gates (rust) fail intermittently.

Writing the script and starting it now happen under one lock (SPAWNING), through a shared start_fake helper that both tests use. Test-only: the real server binary is never freshly written before it is started.

Testing

mkdir -p repro/src repro/tests/unit && cd repro
cp ../desktop/src/server.rs src/
cp ../desktop/tests/unit/server.rs tests/unit/
printf 'mod server;\nfn main() {}\n' > src/main.rs
cat > Cargo.toml <<'EOF'
[package]
name = "desktop-server"
version = "0.1.0"
edition = "2024"
[dependencies]
getrandom = "=0.4.3"
EOF
cargo test --no-run   # then run the printed test binary:
for i in $(seq 400); do ./target/debug/deps/desktop_server-* server::tests -q >/dev/null 2>&1 || echo fail; done | wc -l
failed runs of 400
before 7 (every failure Text file busy, in both tests)
after 0

Summary by cubic

Fixes flaky desktop/tests/unit/server.rs tests that intermittently failed with Text file busy when run in parallel.

The two tests that start a stand-in server script can race: a spawn on one test's thread can fork while the other test's script is still open for writing, and the forked child holds that descriptor until it execs. Writing the script and starting it now happen under one lock, SPAWNING, through a shared start_fake helper that both tests use. This is test-only; the real server binary is never freshly written before it is started.

Written for commit ce07436. Summary will update on new commits.

View guided diff

cubic-dev-ai[bot]

This comment was marked as resolved.

@ColtenOuO
ColtenOuO requested a review from jserv November 22, 2026 23:44
Comment thread desktop/tests/unit/server.rs Resolved
@jserv
jserv requested a review from Patriciaath999 November 23, 2026 01:04
@jserv

jserv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Some review comments on this pull request are not settled yet. Please refine the change per the review comments listed below, reply on each thread with what you changed or why you did not, and mark each thread resolved yourself once it is settled (Resolve conversation, at the bottom of the thread). The pull request stays blocked while review threads are open.

Not addressed at the current head:

Checked at bdc14b7.

The two desktop server tests that start a stand-in server script now
write the script and start it under one lock, through a shared
start_fake helper. Run in parallel, a spawn on one test's thread could
fork while the other test's script was still open for writing, and the
forked child held that descriptor until it exec'd, so starting the
script failed with "Text file busy".

Change-Id: Ia5874ad2171235dd731d0c1aa7259e269fa53afe
@jserv
jserv enabled auto-merge November 23, 2026 06:08
@jserv

jserv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Thank @ColtenOuO for contributing!

@jserv
jserv disabled auto-merge November 23, 2026 07:43
@jserv
jserv merged commit dfad1b9 into sysprog21:main Nov 23, 2026
23 checks passed
@ColtenOuO
ColtenOuO deleted the fix-desktop-etxtbsy branch November 23, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants