From ae8c20f1ca601b6042ef762cfaa9c8f91c0fca69 Mon Sep 17 00:00:00 2001 From: Matthew Jackson <1085847+MattJackson@users.noreply.github.com> Date: Sat, 5 Sep 2026 12:35:03 -0700 Subject: [PATCH] scsi/macos: assert the presence-probe leaves the lock unchanged, not the global bit --- src/scsi/macos.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/scsi/macos.rs b/src/scsi/macos.rs index fc35eda0..8931518a 100644 --- a/src/scsi/macos.rs +++ b/src/scsi/macos.rs @@ -310,6 +310,10 @@ mod tests { #[test] fn presence_probe_does_not_open_a_transport() { let path = Path::new("/dev/freemkv-no-such-device"); + // Snapshot rather than assume `false`: OPEN is a process-global bit any + // concurrent test's live transport can hold, so compare the delta — it + // scopes the check to this call, can't flake, still catches a held lock. + let open_before = OPEN.load(Ordering::Acquire); let t0 = std::time::Instant::now(); let r = drive_has_disc(path); let elapsed = t0.elapsed(); @@ -323,9 +327,10 @@ mod tests { "probe took {elapsed:?}: the transport path's unconditional 500 ms \ post-unmount sleep means this budget can only be met without it" ); - assert!( - !OPEN.load(Ordering::Acquire), - "the probe must not leave the exclusive-transport lock held" + assert_eq!( + OPEN.load(Ordering::Acquire), + open_before, + "the probe must not change the exclusive-transport lock state" ); }