#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "aarch64")
))]
mod supported {
use std::time::Duration;
use supermachine::Image;
pub(super) fn main() -> Result<(), Box<dyn std::error::Error>> {
let park_ko = std::path::PathBuf::from("docs/design/extras/smpark/smpark.ko");
if !park_ko.is_file() {
eprintln!("smpark.ko not found at {}", park_ko.display());
std::process::exit(1);
}
eprintln!("[smpark-smoke] baking with smpark.ko staged...");
let image = Image::builder("rust:1-slim")
.with_name("rust_1_slim_smpark")
.with_memory_mib(512)
.with_extra_file(&park_ko, "/supermachine-smpark.ko")
.build()?;
eprintln!("[smpark-smoke] acquiring + checking /proc/modules...");
let pool = image.pool().min(1).max(1).build()?;
let vm = pool.acquire()?;
let out = vm
.exec_builder()
.argv(["sh", "-c", "cat /proc/modules || true"])
.timeout(Duration::from_secs(5))
.output()?;
let stdout = String::from_utf8_lossy(&out.stdout);
eprintln!("[smpark-smoke] /proc/modules output:\n{stdout}");
if stdout.contains("smpark") {
eprintln!("[smpark-smoke] SUCCESS: smpark loaded");
} else {
eprintln!("[smpark-smoke] FAIL: smpark not in /proc/modules");
std::process::exit(2);
}
Ok(())
}
}
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "aarch64")
))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
supported::main()
}
#[cfg(not(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "aarch64")
)))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("this example requires a linux-x86_64 (KVM) or macos-aarch64 (HVF) host; unsupported on this platform");
Ok(())
}