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