mod harness;
#[allow(unused_imports)]
use std::process::Command;
#[test]
fn hello_world_binary_answers() {
let c = harness::compile("hello(world).\n");
let (out, code) = c.query("hello(X)", &[]);
assert!(out.contains("X = world"), "{out}");
assert_eq!(code, 1);
}
#[test]
#[cfg(target_os = "linux")]
fn binary_links_only_system_libraries() {
let c = harness::compile("hello(world).\n");
let out = Command::new("ldd").arg(&c.bin).output().expect("run ldd");
let text = String::from_utf8_lossy(&out.stdout);
const ALLOWED: &[&str] = &[
"linux-vdso",
"libm.so",
"libgcc_s.so",
"libc.so",
"ld-linux",
];
for line in text.lines() {
let lib = line.split_whitespace().next().unwrap_or("");
if lib.is_empty() {
continue;
}
assert!(
ALLOWED.iter().any(|a| lib.contains(a)),
"unexpected dynamic dependency `{lib}` — the standalone contract \
allows only base system libraries:\n{text}"
);
}
}