use std::path::Path;
use std::process::Command;
const CLANG_AR: &str = "/tmp/clang-ar/clang-apply-replacements.exe";
const RSLEIGH_BIN: &str = env!("CARGO_BIN_EXE_rsleigh");
fn fixture_available() -> bool {
if Path::new(CLANG_AR).exists() {
return true;
}
if std::env::var_os("RSLEIGH_REQUIRE_CLANG_AR_FIXTURE").is_some() {
panic!("clang-apply-replacements fixture missing at {CLANG_AR}");
}
eprintln!("[skip] clang-apply-replacements fixture missing at {CLANG_AR}");
false
}
#[test]
fn x86_64_setne_bool_reaches_return() {
if !fixture_available() {
return;
}
let out = Command::new(RSLEIGH_BIN)
.args([CLANG_AR, "0x1400eb54c"])
.output()
.expect("rsleigh invocation");
assert!(
out.status.success(),
"rsleigh failed:\n{}",
String::from_utf8_lossy(&out.stderr)
);
let text = String::from_utf8(out.stdout).expect("UTF-8");
for line in text.lines() {
let t = line.trim();
if t == "return 0;" {
panic!("stale EAX leaked through SETNE — body reduced to `return 0;`\n{text}");
}
}
assert!(
text.contains("1401e5180")
|| text.contains("DAT_")
|| text.contains("!= 0")
|| text.contains("Load")
|| text.contains("*("),
"return expression doesn't reference the memory compare:\n{text}"
);
}