#![cfg(target_os = "linux")]

use std::process::Command;

#[test]
fn module_b_cli_smoke_transfer() {
    let binary = env!("CARGO_BIN_EXE_tracer-bullet");
    let output = Command::new(binary)
        .args([
            "module-b",
            "--memfd-bytes",
            "134217728",
            "--marker",
            "TRACER_BULLET_SUCCESS",
            "--json",
        ])
        .output()
        .expect("failed to invoke tracer-bullet module-b");

    assert!(
        output.status.success(),
        "module-b CLI failed: status={:?} stderr={} stdout={}",
        output.status,
        String::from_utf8_lossy(&output.stderr),
        String::from_utf8_lossy(&output.stdout)
    );

    let stdout = String::from_utf8_lossy(&output.stdout);
    assert!(stdout.contains("\"module\":\"B\""));
    assert!(stdout.contains("\"marker_ok\":true"));
}

#[test]
#[ignore = "heavy 5GiB memfd transfer"]
fn module_b_cli_full_5g_transfer() {
    let binary = env!("CARGO_BIN_EXE_tracer-bullet");
    let status = Command::new(binary)
        .args(["module-b", "--memfd-bytes", "5368709120", "--json"])
        .status()
        .expect("failed to invoke tracer-bullet module-b for 5GiB test");

    assert!(status.success(), "full 5GiB module-b test failed");
}
