forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-aacflake': serialize env-toggle SBR tests against each other

Browse files at this commit

c11ca7ae8f75f50f0900cdb13449630aeb3b56caAhmet Kaan GümüşParent: 907cb78a7e507d
crates/ec-aac/tests/sbr_real_library.rsmodified+30 -0
@@ -16,6 +16,20 @@ use ec_core::{CodecId, Demuxer, Packet};
16 use ec_matroska::MatroskaDemuxer;16 use ec_matroska::MatroskaDemuxer;
17 use ec_mp4::Mp4Demuxer;17 use ec_mp4::Mp4Demuxer;
18 18
19+/// Every `#[test]` in this file decodes real SBR content through
20+/// `our_decode`/`our_decode_uncapped`, and a handful of them steer that
21+/// decode with process-global env vars (`EC_AAC_SBR_HF_BYPASS`,
22+/// `EC_AAC_SBR_SIDEINFO_DEBUG`, `EC_AAC_SBR_NOISE_ZERO`,
23+/// `EC_AAC_SBR_NOISE_FRACTION`) as debug toggles, set then removed mid-test.
24+/// Cargo runs this binary's tests in parallel threads by default, so an
25+/// unguarded `set_var`/`remove_var` window in one test can flip decode
26+/// behaviour out from under another test's own concurrent decode -- this is
27+/// exactly what turned `sbr_real_library_matches_reference`'s HF-band
28+/// correlation into a full-suite-only flake (`sbr_hf_window_band_probe`
29+/// toggling `EC_AAC_SBR_HF_BYPASS` while it ran). Every test locks this for
30+/// its whole body so no toggle window and no concurrent read can interleave.
31+static DECODE_SERIAL: std::sync::Mutex<()> = std::sync::Mutex::new(());
32+
19 fn have_ffmpeg() -> bool {33 fn have_ffmpeg() -> bool {
20 Command::new("ffmpeg")34 Command::new("ffmpeg")
21 .arg("-version")35 .arg("-version")
@@ -2189,6 +2203,7 @@ fn ffmpeg_decode_at_rate(
2189 /// the crossover at all.2203 /// the crossover at all.
2190 #[test]2204 #[test]
2191 fn core_only_matches_reference() {2205 fn core_only_matches_reference() {
2206+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
2192 if !have_ffmpeg() {2207 if !have_ffmpeg() {
2193 eprintln!("SKIP: ffmpeg not on PATH");2208 eprintln!("SKIP: ffmpeg not on PATH");
2194 return;2209 return;
@@ -2228,6 +2243,7 @@ fn core_only_matches_reference() {
2228 /// that scaling.2243 /// that scaling.
2229 #[test]2244 #[test]
2230 fn dump_sideinfo_kx() {2245 fn dump_sideinfo_kx() {
2246+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
2231 unsafe {2247 unsafe {
2232 std::env::set_var("EC_AAC_SBR_SIDEINFO_DEBUG", "1");2248 std::env::set_var("EC_AAC_SBR_SIDEINFO_DEBUG", "1");
2233 }2249 }
@@ -2261,6 +2277,7 @@ fn dump_sideinfo_kx() {
2261 /// content itself being wrong.2277 /// content itself being wrong.
2262 #[test]2278 #[test]
2263 fn wide_lag_search_full_chain() {2279 fn wide_lag_search_full_chain() {
2280+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
2264 if !have_ffmpeg() {2281 if !have_ffmpeg() {
2265 eprintln!("SKIP: ffmpeg not on PATH");2282 eprintln!("SKIP: ffmpeg not on PATH");
2266 return;2283 return;
@@ -2313,6 +2330,7 @@ fn wide_lag_search_full_chain() {
2313 /// factor (alignment against a reference, different tool, etc.) to blame.2330 /// factor (alignment against a reference, different tool, etc.) to blame.
2314 #[test]2331 #[test]
2315 fn full_chain_low_band_matches_own_core() {2332 fn full_chain_low_band_matches_own_core() {
2333+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
2316 for c in &candidates() {2334 for c in &candidates() {
2317 let Some((core, core_rate)) = our_decode_core_only(&c.path, c.aac_stream) else {2335 let Some((core, core_rate)) = our_decode_core_only(&c.path, c.aac_stream) else {
2318 continue;2336 continue;
@@ -2405,6 +2423,7 @@ fn full_chain_low_band_matches_own_core() {
2405 /// directory is absent.2423 /// directory is absent.
2406 #[test]2424 #[test]
2407 fn synthetic_heaac_matrix() {2425 fn synthetic_heaac_matrix() {
2426+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
2408 if !have_ffmpeg() {2427 if !have_ffmpeg() {
2409 eprintln!("SKIP: ffmpeg not on PATH");2428 eprintln!("SKIP: ffmpeg not on PATH");
2410 return;2429 return;
@@ -2719,6 +2738,7 @@ fn candidates() -> Vec<Candidate> {
2719 /// touches.2738 /// touches.
2720 #[test]2739 #[test]
2721 fn sbr_real_library_matches_reference() {2740 fn sbr_real_library_matches_reference() {
2741+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
2722 if !have_ffmpeg() {2742 if !have_ffmpeg() {
2723 eprintln!("SKIP: ffmpeg not on PATH");2743 eprintln!("SKIP: ffmpeg not on PATH");
2724 return;2744 return;
@@ -3391,6 +3411,7 @@ fn report_conviction(label: &str, rows: &[(f64, f64, f64, f64, f64, f64)]) {
3391 /// need to be recalibrated against whatever this control actually measures.3411 /// need to be recalibrated against whatever this control actually measures.
3392 #[test]3412 #[test]
3393 fn sbr_instrument_anchor_controls() {3413 fn sbr_instrument_anchor_controls() {
3414+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
3394 if std::env::var("EC_AAC_SBR_INSTRUMENT_ANCHOR").is_err() {3415 if std::env::var("EC_AAC_SBR_INSTRUMENT_ANCHOR").is_err() {
3395 eprintln!(3416 eprintln!(
3396 "SKIP (round-41 Task 1): EC_AAC_SBR_INSTRUMENT_ANCHOR=1 cargo test -p ec-aac \3417 "SKIP (round-41 Task 1): EC_AAC_SBR_INSTRUMENT_ANCHOR=1 cargo test -p ec-aac \
@@ -3470,6 +3491,7 @@ fn sbr_instrument_anchor_controls() {
3470 /// ACTUALLY realizes in the output, independent of either prior claim.3491 /// ACTUALLY realizes in the output, independent of either prior claim.
3471 #[test]3492 #[test]
3472 fn sbr_actual_noise_fraction() {3493 fn sbr_actual_noise_fraction() {
3494+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
3473 if std::env::var("EC_AAC_SBR_NOISE_ANCHOR").is_err() {3495 if std::env::var("EC_AAC_SBR_NOISE_ANCHOR").is_err() {
3474 eprintln!(3496 eprintln!(
3475 "SKIP (round-41 Task 2): EC_AAC_SBR_NOISE_ANCHOR=1 cargo test -p ec-aac \3497 "SKIP (round-41 Task 2): EC_AAC_SBR_NOISE_ANCHOR=1 cargo test -p ec-aac \
@@ -3666,6 +3688,7 @@ fn sbr_actual_noise_fraction() {
3666 /// generates nothing.3688 /// generates nothing.
3667 #[test]3689 #[test]
3668 fn sbr_header_feature_table() {3690 fn sbr_header_feature_table() {
3691+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
3669 if !have_ffmpeg() {3692 if !have_ffmpeg() {
3670 eprintln!("SKIP: ffmpeg not on PATH");3693 eprintln!("SKIP: ffmpeg not on PATH");
3671 return;3694 return;
@@ -3915,6 +3938,7 @@ fn per_au_low_band_probe(label: &str, path: &Path, aac_stream: usize) {
3915 3938
3916 #[test]3939 #[test]
3917 fn per_au_low_band_divergence() {3940 fn per_au_low_band_divergence() {
3941+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
3918 if !have_ffmpeg() {3942 if !have_ffmpeg() {
3919 eprintln!("SKIP: ffmpeg not on PATH");3943 eprintln!("SKIP: ffmpeg not on PATH");
3920 return;3944 return;
@@ -3948,6 +3972,7 @@ fn per_au_low_band_divergence() {
3948 /// own_core`'s FMJ probe with `WIDE_LAG_MAX` raised to 100_000.3972 /// own_core`'s FMJ probe with `WIDE_LAG_MAX` raised to 100_000.
3949 #[test]3973 #[test]
3950 fn probe_explicit_config_and_wide_lag() {3974 fn probe_explicit_config_and_wide_lag() {
3975+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
3951 if !have_ffmpeg() {3976 if !have_ffmpeg() {
3952 eprintln!("SKIP: ffmpeg not on PATH");3977 eprintln!("SKIP: ffmpeg not on PATH");
3953 return;3978 return;
@@ -4149,6 +4174,7 @@ fn ffmpeg_decode_pan_channel(path: &Path, absolute_stream: usize, channel: usize
4149 /// (never `-ac 1`, which would remix rather than isolate).4174 /// (never `-ac 1`, which would remix rather than isolate).
4150 #[test]4175 #[test]
4151 fn reelq_multichannel_lc_matches_reference() {4176 fn reelq_multichannel_lc_matches_reference() {
4177+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
4152 if !have_ffmpeg() {4178 if !have_ffmpeg() {
4153 eprintln!("SKIP: ffmpeg not on PATH");4179 eprintln!("SKIP: ffmpeg not on PATH");
4154 return;4180 return;
@@ -4208,6 +4234,7 @@ fn reelq_multichannel_lc_matches_reference() {
4208 /// the swap-shaped-result gate this round adds.4234 /// the swap-shaped-result gate this round adds.
4209 #[test]4235 #[test]
4210 fn coupled_cpe_channel_swap_probe() {4236 fn coupled_cpe_channel_swap_probe() {
4237+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
4211 if !have_ffmpeg() {4238 if !have_ffmpeg() {
4212 eprintln!("SKIP: ffmpeg not on PATH");4239 eprintln!("SKIP: ffmpeg not on PATH");
4213 return;4240 return;
@@ -4537,6 +4564,7 @@ fn narrow_lag_at(
4537 /// (real 44.1k HE-AAC) as controls that are known NOT to show the drift.4564 /// (real 44.1k HE-AAC) as controls that are known NOT to show the drift.
4538 #[test]4565 #[test]
4539 fn sbr441_family_sample_drift_probe() {4566 fn sbr441_family_sample_drift_probe() {
4567+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
4540 if !have_ffmpeg() {4568 if !have_ffmpeg() {
4541 eprintln!("SKIP: ffmpeg not on PATH");4569 eprintln!("SKIP: ffmpeg not on PATH");
4542 return;4570 return;
@@ -4657,6 +4685,7 @@ fn sbr441_family_sample_drift_probe() {
4657 /// readable straight from the printed corr numbers.4685 /// readable straight from the printed corr numbers.
4658 #[test]4686 #[test]
4659 fn sbr_hf_window_band_probe() {4687 fn sbr_hf_window_band_probe() {
4688+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
4660 if !have_ffmpeg() {4689 if !have_ffmpeg() {
4661 eprintln!("SKIP: ffmpeg not on PATH");4690 eprintln!("SKIP: ffmpeg not on PATH");
4662 return;4691 return;
@@ -4761,6 +4790,7 @@ fn sbr_hf_window_band_probe() {
4761 /// band, so it needs no calibration) with an ours-vs-ours self-check column.4790 /// band, so it needs no calibration) with an ours-vs-ours self-check column.
4762 #[test]4791 #[test]
4763 fn sbr_residual_locator() {4792 fn sbr_residual_locator() {
4793+ let _guard = DECODE_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
4764 if !have_ffmpeg() {4794 if !have_ffmpeg() {
4765 return;4795 return;
4766 }4796 }