Skip to content

fix: Serialize HOME-sensitive unit tests - #344

Merged
inureyes merged 1 commit into
mainfrom
fix/issue-335-home-test-locking
Oct 22, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/issue-335-home-test-locking

Conversation

@inureyes

Copy link
Copy Markdown
Member

HOME-sensitive unit tests now share the writer's lock, including indirect reads through SSH configuration resolution, authentication defaults, session policies, and KnownHostsCommand contexts. Existing HOME writers keep their single guard; the helper documents the non-reentrant locking rule.

The plain-key fallback test constructs a KnownHostsCommand context that reads HOME; its script, output, and log use a unique temporary directory. Its original failure did not reproduce (0/1,000 before and after), so this does not claim to establish that flake's cause. Assertion diagnostics now include invocation logs and command output, and tools/test-home-races.py preserves stdout, stderr, backtraces, timeout failures, and a summary for every run.

Validation:

  • Before: 36 failed invocations / 1,000, with 14 tests per invocation; captured HOME mismatches included /home/user/.ssh/other versus /home/inureyes/.ssh/other.
  • After: 0 failed invocations / 1,000 using the same 14 tests, eight concurrent processes and eight test threads each. The selection combines both reported readers, other known-host tests, the fallback test, and the HOME-mutating tilde test.
  • 254 available guarded tests passed in batches of at most 30, each also running the HOME writer; formatting and lib/test clippy passed.

Audit exclusions: app tests run in a separate binary without HOME mutations; keygen tests never call the HOME-reading entrypoint; config-cache tests load explicit paths; the historical interactive_unit_test.rs is not compiled, while its current replacement already locks HOME. Production behavior is unchanged.

Closes #335

@inureyes inureyes added type:test Test related changes priority:low Low priority issue status:review Under review status:done Completed and removed status:review Under review labels Oct 22, 2026
Hold the shared HOME guard across direct readers and SSH configuration, path expansion, authentication, and session policy tests. Keep HOME-mutating tests on their existing guard to avoid reentrant locking.

Add a bounded parallel reproduction tool that preserves every run's output, and include command diagnostics in the plain-key fallback assertion. The 1,000-run baseline failed 36 times; the same 14-test selection passed all 1,000 runs after locking.
@inureyes
inureyes force-pushed the fix/issue-335-home-test-locking branch from 7228731 to 836bde4 Compare October 22, 2026 14:18
@inureyes
inureyes merged commit ba996c7 into main Oct 22, 2026
5 checks passed
@inureyes
inureyes deleted the fix/issue-335-home-test-locking branch October 22, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:low Low priority issue status:done Completed type:test Test related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: serialize unit tests that read HOME against EnvGuard mutations

1 participant