use std::path::Path;
use std::process::Command;
const GIT_REPACK: &str = "/tmp/git-repack/git-repack";
const RSLEIGH_BIN: &str = env!("CARGO_BIN_EXE_rsleigh");
fn fixture_available() -> bool {
if Path::new(GIT_REPACK).exists() {
return true;
}
if std::env::var_os("RSLEIGH_REQUIRE_GIT_REPACK_FIXTURE").is_some() {
panic!("git-repack fixture missing at {GIT_REPACK}");
}
eprintln!("[skip] git-repack fixture missing at {GIT_REPACK}");
false
}
#[test]
fn bswap64_upper_half_shift_survives_simba() {
if !fixture_available() {
return;
}
let out = Command::new(RSLEIGH_BIN)
.args([GIT_REPACK, "0x49ae98"])
.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("ff00ff00ff00ff00"),
"upper bswap mask ff00ff00ff00ff00 missing — SiMBA likely zeroed the `>> 8` half\n{text}"
);
assert!(
text.contains(" >> 8") || text.contains(">>8"),
"no `>> 8` operation — bswap byte-swap half got folded out\n{text}"
);
assert!(
text.contains(" | "),
"no OR operator — bswap halves not joined\n{text}"
);
}