Skip to content

test: extract the duplicated subprocess crash harness into tests/common #327

Closed

Description

@adityamukho

Summary

tests/wal_test.rs and tests/migration_matrix_test.rs contain byte-identical copies of the subprocess crash-simulation harness — roughly 120 lines: CRASH_CHILD_SPAWN_LOCK, CrashTx, run_crashing_child, and crash_child_entrypoint.

Background

The harness arrived with the kernel-locking work. std::mem::forget stopped modelling a crash once the lock moved into the kernel: forgetting the handle leaks the File, so its descriptor stays open and the lock is held for the whole life of the test process. The replacement spawns a real child that opens, writes, and abort()s, which is what production actually does.

Integration test crates cannot share code directly, so the harness was duplicated deliberately rather than carelessly. The tell that it is now a liability is #[allow(dead_code)] on CrashTx::Explicit in migration_matrix_test.rs — a variant that exists there only because it was copied.

Why it matters

Someone fixes a defect in one copy and not the other — the status.code().unwrap_or(1) predicate, say, or the \u{1e} statement separator — and the two crash harnesses silently diverge. One test file then stops testing what its comments claim, with nothing failing to signal it.

Task

  • Extract the harness into tests/common/mod.rs
  • Have both files mod common;
  • Drop the now-unnecessary #[allow(dead_code)]
  • Confirm both suites stay green under default parallelism

Not urgent: both copies are currently correct and this is test-only. It should not be left indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions