@@ -44,40 +44,38 @@ fn auxv_dump() {
44
44
#[ cfg( feature = "std_detect_file_io" ) ]
45
45
cfg_if:: cfg_if! {
46
46
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!`.
47
49
#[ test]
48
50
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( ) ;
52
53
assert_eq!( v. hwcap, 4174038 ) ;
53
54
assert_eq!( v. hwcap2, 16 ) ;
54
55
}
55
56
56
57
#[ test]
57
58
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" ) ) ;
60
60
// 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( ) ;
62
62
assert_eq!( v. hwcap, 126614527 ) ;
63
63
assert_eq!( v. hwcap2, 0 ) ;
64
64
}
65
65
} else if #[ cfg( target_arch = "aarch64" ) ] {
66
66
#[ cfg( target_endian = "little" ) ]
67
67
#[ test]
68
68
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( ) ;
72
71
assert_eq!( v. hwcap, 0x0123456789abcdef ) ;
73
72
assert_eq!( v. hwcap2, 0x02468ace13579bdf ) ;
74
73
}
75
74
#[ cfg( target_endian = "little" ) ]
76
75
#[ test]
77
76
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( ) ;
81
79
// An absent HWCAP2 is treated as zero, and does not prevent acceptance of HWCAP.
82
80
assert_ne!( v. hwcap, 0 ) ;
83
81
assert_eq!( v. hwcap2, 0 ) ;
0 commit comments