#[test]
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[ignore = "environment-dependent: emulates the host's real /bin/ls over its real glibc, so \
success hinges on the exact glibc/coreutils build. Reliable on a tuned host (Arch), \
but the CI runners' glibc diverges. Run on demand with --ignored."]
fn elf64lin_real_ls_full_emulation() {
use crate::tests::helpers;
use crate::*;
helpers::setup();
let ls = "/bin/ls";
if !std::path::Path::new(ls).exists() {
eprintln!("skipping: {} not present on host", ls);
return;
}
let head = std::fs::read(ls).unwrap_or_default();
let is_elf64_x64 = head.len() > 18
&& &head[0..4] == b"\x7fELF"
&& head[4] == 2 && head[18] == 0x3e; if !is_elf64_x64 {
eprintln!("skipping: {} is not an x86_64 ELF on this host", ls);
return;
}
let mut emu = emu64();
emu.cfg.linux_real_libc = true;
emu.max_pos = Some(20_000_000);
emu.load_code(ls);
assert!(emu.cfg.arch.is_x64());
assert!(emu.os.is_linux(), "expected the Linux loader path");
let _ = emu.run(None);
assert!(
emu.max_pos.map(|cap| emu.pos < cap).unwrap_or(true),
"ls did not terminate: hit the {:?}-instruction cap at pos {}",
emu.max_pos,
emu.pos
);
assert_eq!(
emu.regs().rdi,
0,
"ls should exit(0); got exit({})",
emu.regs().rdi
);
}