Skip to content

Commit fa60abb

Browse files
committed
sanity check that symbol resolution functions correctly
1 parent df66e24 commit fa60abb

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/checks.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ jobs:
282282
LD_LIBRARY_PATH: "target/${{matrix.target}}/release/deps"
283283
working-directory: libz-rs-sys-cdylib
284284
run: |
285-
cargo build --release --target ${{matrix.target}} --no-default-features --features="rust-allocator"
285+
cargo build --release --target ${{matrix.target}} --no-default-features --features="export-symbols,rust-allocator"
286286
cc -o zpipe zpipe.c target/${{matrix.target}}/release/deps/libz_rs.so
287287
./zpipe < Cargo.toml | ./zpipe -d > out.txt
288288
cmp -s Cargo.toml out.txt
@@ -291,7 +291,7 @@ jobs:
291291
LD_LIBRARY_PATH: "target/${{matrix.target}}/release/deps"
292292
working-directory: libz-rs-sys-cdylib
293293
run: |
294-
cargo build --release --target ${{matrix.target}} --no-default-features
294+
cargo build --release --target ${{matrix.target}} --no-default-features --features="export-symbols"
295295
cc -DNO_STD -o zpipe zpipe.c target/${{matrix.target}}/release/deps/libz_rs.so
296296
./zpipe < Cargo.toml | ./zpipe -d > out.txt
297297
cmp -s Cargo.toml out.txt

test-libz-rs-sys/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ macro_rules! extract_error_message {
4949
};
5050
}
5151

52+
/// a bit of a sanity check that nothing weird happened with symbol resolution
53+
#[cfg(not(miri))]
54+
#[cfg(test)]
55+
#[test]
56+
fn zlib_rs_is_not_zlib_ng() {
57+
use std::ffi::CStr;
58+
59+
unsafe {
60+
let rs = CStr::from_ptr(libz_rs_sys::zlibVersion());
61+
assert!(rs.to_str().unwrap().contains("zlib-rs"));
62+
63+
let ng = CStr::from_ptr(libz_sys::zlibVersion());
64+
assert!(ng.to_str().unwrap().contains("zlib-ng"));
65+
}
66+
}
67+
5268
#[cfg(test)]
5369
mod null {
5470
use core::mem::MaybeUninit;

0 commit comments

Comments
 (0)