// Contract tests for the standalone UVC launcher shell script.
//
// Scope: statically guard `scripts/daemon/lesavka-uvc.sh`.
// Targets: gadget-node discovery and wrong-device avoidance.
// Why: falling back to an unrelated `/dev/video0` can wedge the helper in
// kernel space and poison later gadget recovery loops.

const UVC_SCRIPT: &str = include_str!(concat!(
    env!("CARGO_MANIFEST_DIR"),
    "/scripts/daemon/lesavka-uvc.sh"
));

#[test]
fn uvc_script_waits_for_gadget_by_path_node() {
    for expected in [
        "resolve_default_uvc_dev()",
        "wait_for_uvc_dev()",
        "platform-%s-video-index0",
        "platform-*-video-index0",
        "gadget video_output node is still absent",
    ] {
        assert!(
            UVC_SCRIPT.contains(expected),
            "lesavka-uvc launcher guard missing: {expected}"
        );
    }
}

#[test]
fn uvc_script_refuses_unrelated_video0_fallback() {
    assert!(
        !UVC_SCRIPT.contains("DEV=/dev/video0"),
        "lesavka-uvc launcher must not fall back to an unrelated /dev/video0"
    );
}
