ci(lesavka): stabilize safe gate coverage
This commit is contained in:
parent
147845d079
commit
8ed19c4311
@ -20,6 +20,7 @@ use lesavka_common::lesavka::AudioPacket;
|
|||||||
|
|
||||||
#[path = "ear_capture/source_watchdog.rs"]
|
#[path = "ear_capture/source_watchdog.rs"]
|
||||||
mod source_watchdog;
|
mod source_watchdog;
|
||||||
|
#[cfg(not(coverage))]
|
||||||
use source_watchdog::{AudioSourceHealth, spawn_audio_source_watchdog};
|
use source_watchdog::{AudioSourceHealth, spawn_audio_source_watchdog};
|
||||||
|
|
||||||
/// “Speaker” stream coming **from** the remote host (UAC2‑gadget playback
|
/// “Speaker” stream coming **from** the remote host (UAC2‑gadget playback
|
||||||
|
|||||||
@ -138,6 +138,15 @@ pub fn spawn_uvc_control(bin: &str, uvc_dev: &str) -> anyhow::Result<tokio::proc
|
|||||||
.context("spawning lesavka-uvc")
|
.context("spawning lesavka-uvc")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn uvc_control_restart_delay() -> Duration {
|
||||||
|
let millis = std::env::var("LESAVKA_UVC_RESTART_DELAY_MS")
|
||||||
|
.ok()
|
||||||
|
.and_then(|value| value.parse::<u64>().ok())
|
||||||
|
.unwrap_or(2_000)
|
||||||
|
.min(10_000);
|
||||||
|
Duration::from_millis(millis)
|
||||||
|
}
|
||||||
|
|
||||||
/// Supervise the external UVC control helper forever.
|
/// Supervise the external UVC control helper forever.
|
||||||
///
|
///
|
||||||
/// Inputs: the helper binary path.
|
/// Inputs: the helper binary path.
|
||||||
@ -193,7 +202,7 @@ pub async fn supervise_uvc_control(bin: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
tokio::time::sleep(uvc_control_restart_delay()).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,9 +5,9 @@ use std::sync::atomic::Ordering;
|
|||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
use super::hevc_mjpeg_guard;
|
use super::hevc_mjpeg_guard;
|
||||||
use super::mjpeg_spool::{
|
#[cfg(not(coverage))]
|
||||||
MjpegSpoolTiming, freshest_mjpeg_sample, spool_mjpeg_frame_with_timing,
|
use super::mjpeg_spool::freshest_mjpeg_sample;
|
||||||
};
|
use super::mjpeg_spool::{MjpegSpoolTiming, spool_mjpeg_frame_with_timing};
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::video_support::{contains_hevc_irap, reserve_local_pts};
|
use crate::video_support::{contains_hevc_irap, reserve_local_pts};
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use serial_test::serial;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use temp_env::with_var;
|
use temp_env::{with_var, with_vars};
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
|
||||||
@ -76,17 +76,23 @@ fn supervise_uvc_control_restarts_helper_after_exit() {
|
|||||||
fs::set_permissions(&helper, perms).expect("chmod helper script");
|
fs::set_permissions(&helper, perms).expect("chmod helper script");
|
||||||
|
|
||||||
let helper_path = helper.to_string_lossy().to_string();
|
let helper_path = helper.to_string_lossy().to_string();
|
||||||
with_var("LESAVKA_UVC_DEV", Some("/dev/video-loop"), || {
|
with_vars(
|
||||||
|
[
|
||||||
|
("LESAVKA_UVC_DEV", Some("/dev/video-loop")),
|
||||||
|
("LESAVKA_UVC_RESTART_DELAY_MS", Some("25")),
|
||||||
|
],
|
||||||
|
|| {
|
||||||
let rt = Runtime::new().expect("runtime");
|
let rt = Runtime::new().expect("runtime");
|
||||||
let result = rt.block_on(async {
|
let result = rt.block_on(async {
|
||||||
tokio::time::timeout(
|
tokio::time::timeout(
|
||||||
Duration::from_millis(2_450),
|
Duration::from_millis(450),
|
||||||
supervise_uvc_control(helper_path),
|
supervise_uvc_control(helper_path),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
});
|
});
|
||||||
assert!(result.is_err(), "supervisor should still be running");
|
assert!(result.is_err(), "supervisor should still be running");
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let calls = fs::read_to_string(marker).expect("read helper marker");
|
let calls = fs::read_to_string(marker).expect("read helper marker");
|
||||||
let restart_count = calls
|
let restart_count = calls
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user