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 func_with_calls_not_emitted_as_thunk() {
if !fixture_available() {
return;
}
let out = Command::new(RSLEIGH_BIN)
.args([CLANG_AR, "0x140123110"])
.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");
assert!(
!text.contains("// thunk"),
"function with real calls misdetected as thunk:\n{text}"
);
assert!(
!text.contains("func_140123123"),
"self-loop block address emitted as fake thunk target:\n{text}"
);
}