test(flash): gate sd_media host-tool tests to unix (fix Windows/Wine verify)
The verify-windows gate runs the unit tests under Wine. The card-building tests shell out to unix tools (sfdisk/mkfs.vfat/mtools/cpio/gzip); their find_tool-based runtime skip sees those binaries in the shared container filesystem and does NOT skip, but a Windows process under Wine cannot exec a Linux ELF, so injects_install_hook_into_initramfs failed. Card building is a unix-host operation, so cfg(unix) the four tool-invoking tests and their helpers. On the Windows target they are not compiled (no Wine exec, no dead-code warnings); the three pure tests (sanitize labels, script targets the boot slots, rejects a bad package -- which errors before any tool) still run everywhere. Native keeps all 7 sd_media tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -705,6 +705,12 @@ mod tests {
|
||||
/// Build a fake vendor SD-recovery package (nested like the real one) and
|
||||
/// assemble a stock-recovery card image from it, then read the card back
|
||||
/// with `mdir`/`mtype` and confirm the layout and content survived.
|
||||
///
|
||||
/// Host-tool test: unix only. On a Windows target (incl. the Wine CI run)
|
||||
/// the card-building tools are unix binaries that a Windows process cannot
|
||||
/// exec, and `find_tool` would see them as present in the shared container
|
||||
/// filesystem, so these are cfg'd out rather than skipped at runtime.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn builds_a_stock_recovery_card_from_a_vendor_package() {
|
||||
// Skip cleanly if the host lacks the tools (keeps CI green where the
|
||||
@@ -789,12 +795,14 @@ mod tests {
|
||||
assert_eq!(sanitize_label("ANTMINER"), "ANTMINER");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn have_tools(tools: &[&str]) -> bool {
|
||||
tools.iter().all(|t| find_tool(t).is_ok())
|
||||
}
|
||||
|
||||
/// A minimal gzipped newc cpio containing `etc/` + a probe file, to stand in
|
||||
/// for an afw rootfs in the installer-initramfs tests.
|
||||
#[cfg(unix)]
|
||||
fn fake_cpio_gz(dir: &Path) -> Vec<u8> {
|
||||
fs::create_dir_all(dir.join("etc/init.d")).unwrap();
|
||||
fs::write(dir.join("probe"), b"hello-rootfs").unwrap();
|
||||
@@ -824,10 +832,12 @@ mod tests {
|
||||
gz.wait_with_output().unwrap().stdout
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn uimage_magic(bytes: &[u8]) -> bool {
|
||||
bytes.len() >= 4 && bytes[0..4] == [0x27, 0x05, 0x19, 0x56]
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn mtype_bytes(img: &Path, card_path: &str) -> Vec<u8> {
|
||||
let tmp = tempdir::TempHold::new().unwrap();
|
||||
let rc = tmp.path().join("rc");
|
||||
@@ -849,6 +859,7 @@ mod tests {
|
||||
.stdout
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn injects_install_hook_into_initramfs() {
|
||||
if !have_tools(&["cpio", "gzip", "gunzip", "find"]) {
|
||||
@@ -892,6 +903,7 @@ mod tests {
|
||||
assert!(ex.join("probe").is_file(), "original rootfs content lost");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn builds_a_zynq_simpleboot_card() {
|
||||
if !have_tools(&["sfdisk", "mkfs.vfat", "mcopy", "mmd", "mdir", "mtype"]) {
|
||||
@@ -913,6 +925,7 @@ mod tests {
|
||||
assert_eq!(mtype_bytes(&out, "devicetree.dtb"), b"ALKANE-FDT");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn builds_a_zynq_installer_card() {
|
||||
if !have_tools(&[
|
||||
|
||||
Reference in New Issue
Block a user