@@ -4,36 +4,32 @@ use std::{
44 fs:: { self , Permissions } ,
55 os:: unix:: fs:: PermissionsExt as _,
66 path:: { Path , PathBuf } ,
7- str:: from_utf8,
87 sync:: LazyLock ,
98} ;
109
1110use fspy:: PathAccessIterable ;
11+ use fspy_shared_unix:: is_dynamically_linked_to_libc;
1212
1313use crate :: test_utils:: assert_contains;
1414
1515mod test_utils;
1616
17- const PRELOAD_CDYLIB_BINARY : & [ u8 ] = include_bytes ! ( env!( "CARGO_BIN_FILE_FSPY_TEST_BIN" ) ) ;
17+ const TEST_BIN_CONTENT : & [ u8 ] = include_bytes ! ( env!( "CARGO_BIN_FILE_FSPY_TEST_BIN" ) ) ;
1818
1919fn test_bin_path ( ) -> & ' static Path {
2020 static TEST_BIN_PATH : LazyLock < PathBuf > = LazyLock :: new ( || {
21+ assert_eq ! (
22+ is_dynamically_linked_to_libc( & TEST_BIN_CONTENT ) ,
23+ Ok ( false ) ,
24+ "Test binary is not a static executable"
25+ ) ;
26+
2127 let tmp_dir = env ! ( "CARGO_TARGET_TMPDIR" ) ;
2228 let test_bin_path = PathBuf :: from ( tmp_dir) . join ( "fspy-test-bin" ) ;
23- fs:: write ( & test_bin_path, PRELOAD_CDYLIB_BINARY ) . expect ( "failed to write test binary" ) ;
29+ fs:: write ( & test_bin_path, TEST_BIN_CONTENT ) . expect ( "failed to write test binary" ) ;
2430 fs:: set_permissions ( & test_bin_path, Permissions :: from_mode ( 0o755 ) )
2531 . expect ( "failed to set permissions on test binary" ) ;
2632
27- // Verify that the test binary is indeed a static executable
28- let output = std:: process:: Command :: new ( "ldd" ) . arg ( & test_bin_path) . output ( ) . unwrap ( ) ;
29- assert_eq ! (
30- output. status. code( ) ,
31- Some ( 1 ) ,
32- "ldd should fail on static executables. Stdout: {}. Stderr: {}" ,
33- from_utf8( & output. stdout) . unwrap( ) ,
34- from_utf8( & output. stderr) . unwrap( )
35- ) ;
36-
3733 test_bin_path
3834 } ) ;
3935 TEST_BIN_PATH . as_path ( )
0 commit comments