Skip to content

Commit e2bb632

Browse files
yannhamclaude
andcommitted
test(ffi): assert cdylib exists and is readable before ELF inspection
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e6a7b10 commit e2bb632

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

libdd-otel-thread-ctx-ffi/tests/elf_properties.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,27 @@ use std::process::Command;
1818
const SYMBOL: &str = "otel_thread_ctx_v1";
1919

2020
fn cdylib_path() -> PathBuf {
21-
PathBuf::from(env!("CDYLIB_PROFILE_DIR")).join("liblibdd_otel_thread_ctx_ffi.so")
21+
let path = PathBuf::from(env!("CDYLIB_PROFILE_DIR")).join("liblibdd_otel_thread_ctx_ffi.so");
22+
assert!(
23+
path.exists(),
24+
"cdylib not found at {}: \
25+
ensure `cargo build -p libdd-otel-thread-ctx-ffi` has been run for this profile",
26+
path.display()
27+
);
28+
assert!(
29+
std::fs::File::open(&path).is_ok(),
30+
"cdylib exists at {} but could not be opened for reading",
31+
path.display()
32+
);
33+
path
2234
}
2335

2436
fn readelf(args: &[&str], path: &PathBuf) -> String {
2537
let out = Command::new("readelf")
2638
.args(args)
2739
.arg(path)
2840
.output()
29-
.expect("failed to run readelf — is binutils installed?");
41+
.expect("failed to run readelf. Is binutils installed?");
3042
String::from_utf8_lossy(&out.stdout).into_owned()
3143
}
3244

0 commit comments

Comments
 (0)