@@ -44,40 +44,38 @@ fn auxv_dump() {
4444#[ cfg( feature = "std_detect_file_io" ) ]
4545cfg_if:: cfg_if! {
4646 if #[ cfg( target_arch = "arm" ) ] {
47+ // The tests below can be executed under qemu, where we do not have access to the test
48+ // files on disk, so we need to embed them with `include_bytes!`.
4749 #[ test]
4850 fn linux_rpi3( ) {
49- let file = concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-rpi3.auxv" ) ;
50- println!( "file: {file}" ) ;
51- let v = auxv_from_file( file) . unwrap( ) ;
51+ let auxv = include_bytes!( concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-rpi3.auxv" ) ) ;
52+ let v = auxv_from_file_bytes( auxv) . unwrap( ) ;
5253 assert_eq!( v. hwcap, 4174038 ) ;
5354 assert_eq!( v. hwcap2, 16 ) ;
5455 }
5556
5657 #[ test]
5758 fn linux_macos_vb( ) {
58- let file = concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv" ) ;
59- println!( "file: {file}" ) ;
59+ let auxv = include_bytes!( concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv" ) ) ;
6060 // The file contains HWCAP but not HWCAP2. In that case, we treat HWCAP2 as zero.
61- let v = auxv_from_file ( file ) . unwrap( ) ;
61+ let v = auxv_from_file_bytes ( auxv ) . unwrap( ) ;
6262 assert_eq!( v. hwcap, 126614527 ) ;
6363 assert_eq!( v. hwcap2, 0 ) ;
6464 }
6565 } else if #[ cfg( target_arch = "aarch64" ) ] {
6666 #[ cfg( target_endian = "little" ) ]
6767 #[ test]
6868 fn linux_artificial_aarch64( ) {
69- let file = concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-artificial-aarch64.auxv" ) ;
70- println!( "file: {file}" ) ;
71- let v = auxv_from_file( file) . unwrap( ) ;
69+ let auxv = include_bytes!( concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-artificial-aarch64.auxv" ) ) ;
70+ let v = auxv_from_file_bytes( auxv) . unwrap( ) ;
7271 assert_eq!( v. hwcap, 0x0123456789abcdef ) ;
7372 assert_eq!( v. hwcap2, 0x02468ace13579bdf ) ;
7473 }
7574 #[ cfg( target_endian = "little" ) ]
7675 #[ test]
7776 fn linux_no_hwcap2_aarch64( ) {
78- let file = concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-no-hwcap2-aarch64.auxv" ) ;
79- println!( "file: {file}" ) ;
80- let v = auxv_from_file( file) . unwrap( ) ;
77+ let auxv = include_bytes!( concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-no-hwcap2-aarch64.auxv" ) ) ;
78+ let v = auxv_from_file_bytes( auxv) . unwrap( ) ;
8179 // An absent HWCAP2 is treated as zero, and does not prevent acceptance of HWCAP.
8280 assert_ne!( v. hwcap, 0 ) ;
8381 assert_eq!( v. hwcap2, 0 ) ;
0 commit comments