From 265d21b0c45d1d1fc536adabc43bb67e651b9338 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Thu, 27 Nov 2025 16:24:56 +0100 Subject: [PATCH] misc: improve test idempotence (unrelated improvement) Signed-off-by: Philipp Schuster On-behalf-of: SAP philipp.schuster@sap.com --- virtio-devices/src/vsock/unix/muxer.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/virtio-devices/src/vsock/unix/muxer.rs b/virtio-devices/src/vsock/unix/muxer.rs index ee2264476..edce5b1e0 100644 --- a/virtio-devices/src/vsock/unix/muxer.rs +++ b/virtio-devices/src/vsock/unix/muxer.rs @@ -871,6 +871,7 @@ impl VsockMuxer { #[cfg(test)] mod unit_tests { use std::cmp::min; + use std::fs; use std::io::Write; use std::path::{Path, PathBuf}; @@ -921,6 +922,8 @@ mod unit_tests { ) .unwrap(); let uds_path = format!("test_vsock_{name}.sock"); + // Clear in case it is still there from a previous run + let _ = fs::remove_file(&uds_path); let muxer = VsockMuxer::new(PEER_CID, uds_path).unwrap(); Self { @@ -1049,6 +1052,9 @@ mod unit_tests { } impl LocalListener { fn new + Clone>(path: P) -> Self { + // Clear in case it is still there from a previous run + let _ = fs::remove_file(path.as_ref()); + let path_buf = path.as_ref().to_path_buf(); let sock = UnixListener::bind(path).unwrap(); sock.set_nonblocking(true).unwrap();