Key the probe stream's temp file per call, not per process
Browse files at this commitf9d5fb9f20479cf169ecf978979fd9b5853e6644Parent: 417cf64- fix
- key the probe stream's temp file per call, not per process
1 changed file +9 -1
crates/ec-av1/src/encode.rsmodified+9 -1
| @@ -2682,7 +2682,15 @@ mod tests { | |||
| 2682 | /// frame size an AV1 decoder allocates, not necessarily the render size | 2682 | /// frame size an AV1 decoder allocates, not necessarily the render size |
| 2683 | /// (see [`a_frame_round_trips_at_its_own_size`]). | 2683 | /// (see [`a_frame_round_trips_at_its_own_size`]). |
| 2684 | fn ffprobe_size(stream: &[u8]) -> (u32, u32) { | 2684 | fn ffprobe_size(stream: &[u8]) -> (u32, u32) { |
| 2685 | - let path = std::env::temp_dir().join(format!("ec-av1-probe-{}.obu", std::process::id())); | 2685 | + // Distinct per call, not per process: the test binary runs callers on |
| 2686 | + // parallel threads, and a shared name lets one test's cleanup delete | ||
| 2687 | + // the stream another test's ffprobe is still reading. | ||
| 2688 | + static PROBE_SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); | ||
| 2689 | + let path = std::env::temp_dir().join(format!( | ||
| 2690 | + "ec-av1-probe-{}-{}.obu", | ||
| 2691 | + std::process::id(), | ||
| 2692 | + PROBE_SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed) | ||
| 2693 | + )); | ||
| 2686 | let _ = std::fs::remove_file(&path); | 2694 | let _ = std::fs::remove_file(&path); |
| 2687 | std::fs::write(&path, stream).expect("writing the probe stream"); | 2695 | std::fs::write(&path, stream).expect("writing the probe stream"); |
| 2688 | let out = Command::new("ffprobe") | 2696 | let out = Command::new("ffprobe") |