@@ -224,116 +224,4 @@ fn auxv_from_buf(buf: &[usize]) -> Result<AuxVec, ()> {
224224}
225225
226226#[ cfg( test) ]
227- mod tests {
228- use super :: * ;
229-
230- // FIXME: on mips/mips64 getauxval returns 0, and /proc/self/auxv
231- // does not always contain the AT_HWCAP key under qemu.
232- #[ cfg( any(
233- target_arch = "arm" ,
234- target_arch = "powerpc" ,
235- target_arch = "powerpc64" ,
236- target_arch = "s390x" ,
237- ) ) ]
238- #[ test]
239- fn auxv_crate ( ) {
240- let v = auxv ( ) ;
241- if let Ok ( hwcap) = getauxval ( AT_HWCAP ) {
242- let rt_hwcap = v. expect ( "failed to find hwcap key" ) . hwcap ;
243- assert_eq ! ( rt_hwcap, hwcap) ;
244- }
245-
246- // Targets with AT_HWCAP and AT_HWCAP2:
247- #[ cfg( any(
248- target_arch = "aarch64" ,
249- target_arch = "arm" ,
250- target_arch = "powerpc" ,
251- target_arch = "powerpc64" ,
252- target_arch = "s390x" ,
253- ) ) ]
254- {
255- if let Ok ( hwcap2) = getauxval ( AT_HWCAP2 ) {
256- let rt_hwcap2 = v. expect ( "failed to find hwcap2 key" ) . hwcap2 ;
257- assert_eq ! ( rt_hwcap2, hwcap2) ;
258- }
259- }
260- }
261-
262- #[ test]
263- fn auxv_dump ( ) {
264- if let Ok ( auxvec) = auxv ( ) {
265- println ! ( "{:?}" , auxvec) ;
266- } else {
267- println ! ( "both getauxval() and reading /proc/self/auxv failed!" ) ;
268- }
269- }
270-
271- #[ cfg( feature = "std_detect_file_io" ) ]
272- cfg_if:: cfg_if! {
273- if #[ cfg( target_arch = "arm" ) ] {
274- #[ test]
275- fn linux_rpi3( ) {
276- let file = concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-rpi3.auxv" ) ;
277- println!( "file: {file}" ) ;
278- let v = auxv_from_file( file) . unwrap( ) ;
279- assert_eq!( v. hwcap, 4174038 ) ;
280- assert_eq!( v. hwcap2, 16 ) ;
281- }
282-
283- #[ test]
284- fn linux_macos_vb( ) {
285- let file = concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv" ) ;
286- println!( "file: {file}" ) ;
287- // The file contains HWCAP but not HWCAP2. In that case, we treat HWCAP2 as zero.
288- let v = auxv_from_file( file) . unwrap( ) ;
289- assert_eq!( v. hwcap, 126614527 ) ;
290- assert_eq!( v. hwcap2, 0 ) ;
291- }
292- } else if #[ cfg( target_arch = "aarch64" ) ] {
293- #[ cfg( target_endian = "little" ) ]
294- #[ test]
295- fn linux_artificial_aarch64( ) {
296- let file = concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-artificial-aarch64.auxv" ) ;
297- println!( "file: {file}" ) ;
298- let v = auxv_from_file( file) . unwrap( ) ;
299- assert_eq!( v. hwcap, 0x0123456789abcdef ) ;
300- assert_eq!( v. hwcap2, 0x02468ace13579bdf ) ;
301- }
302- #[ cfg( target_endian = "little" ) ]
303- #[ test]
304- fn linux_no_hwcap2_aarch64( ) {
305- let file = concat!( env!( "CARGO_MANIFEST_DIR" ) , "/src/detect/test_data/linux-no-hwcap2-aarch64.auxv" ) ;
306- println!( "file: {file}" ) ;
307- let v = auxv_from_file( file) . unwrap( ) ;
308- // An absent HWCAP2 is treated as zero, and does not prevent acceptance of HWCAP.
309- assert_ne!( v. hwcap, 0 ) ;
310- assert_eq!( v. hwcap2, 0 ) ;
311- }
312- }
313- }
314-
315- #[ test]
316- #[ cfg( feature = "std_detect_file_io" ) ]
317- fn auxv_dump_procfs ( ) {
318- if let Ok ( auxvec) = auxv_from_file ( "/proc/self/auxv" ) {
319- println ! ( "{:?}" , auxvec) ;
320- } else {
321- println ! ( "reading /proc/self/auxv failed!" ) ;
322- }
323- }
324-
325- #[ cfg( any(
326- target_arch = "aarch64" ,
327- target_arch = "arm" ,
328- target_arch = "powerpc" ,
329- target_arch = "powerpc64" ,
330- target_arch = "s390x" ,
331- ) ) ]
332- #[ test]
333- #[ cfg( feature = "std_detect_file_io" ) ]
334- fn auxv_crate_procfs ( ) {
335- if let Ok ( procfs_auxv) = auxv_from_file ( "/proc/self/auxv" ) {
336- assert_eq ! ( auxv( ) . unwrap( ) , procfs_auxv) ;
337- }
338- }
339- }
227+ mod tests;
0 commit comments