#[test]
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[ignore = "environment-dependent self-emulation ratchet; build mwemu first, then run with --ignored"]
fn self_emulation_reaches_1m_instructions() {
use crate::tests::helpers;
use crate::*;
helpers::setup();
let manifest = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let candidates = [
manifest.join("../../target/release/mwemu"),
manifest.join("../../target/debug/mwemu"),
];
let bin = match candidates.iter().find(|p| p.is_file()) {
Some(p) => p.to_string_lossy().into_owned(),
None => {
eprintln!("skipping: no built mwemu binary — run `cargo build --release` first");
return;
}
};
let mut emu = emu64();
emu.cfg.linux_real_libc = true; emu.max_pos = Some(2_000_000);
emu.load_code(&bin);
let _ = emu.run(None);
const FLOOR: u64 = 900_000;
assert!(
emu.pos >= FLOOR,
"mwemu self-emulated only {} instructions (need >= {}). It stopped at \
rip=0x{:x} — that instruction/syscall is the next one to implement.",
emu.pos,
FLOOR,
emu.regs().rip,
);
}