Skip to content

Commit e07a1bb

Browse files
committed
Move tests around to appease tidy
1 parent 8dc2abb commit e07a1bb

File tree

8 files changed

+258
-262
lines changed

8 files changed

+258
-262
lines changed

library/std_detect/src/detect/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ macro_rules! features {
131131
};
132132
}
133133

134-
#[test]
134+
#[test] //tidy:skip
135135
#[deny(unexpected_cfgs)]
136136
#[deny(unfulfilled_lint_expectations)]
137137
fn unexpected_cfgs() {

library/std_detect/src/detect/os/linux/aarch64.rs

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -395,84 +395,4 @@ impl AtHwcap {
395395

396396
#[cfg(target_endian = "little")]
397397
#[cfg(test)]
398-
mod tests {
399-
use super::*;
400-
401-
#[cfg(feature = "std_detect_file_io")]
402-
mod auxv_from_file {
403-
use super::auxvec::auxv_from_file;
404-
use super::*;
405-
// The baseline hwcaps used in the (artificial) auxv test files.
406-
fn baseline_hwcaps() -> AtHwcap {
407-
AtHwcap {
408-
fp: true,
409-
asimd: true,
410-
aes: true,
411-
pmull: true,
412-
sha1: true,
413-
sha2: true,
414-
crc32: true,
415-
atomics: true,
416-
fphp: true,
417-
asimdhp: true,
418-
asimdrdm: true,
419-
lrcpc: true,
420-
dcpop: true,
421-
asimddp: true,
422-
ssbs: true,
423-
..AtHwcap::default()
424-
}
425-
}
426-
427-
#[test]
428-
fn linux_empty_hwcap2_aarch64() {
429-
let file = concat!(
430-
env!("CARGO_MANIFEST_DIR"),
431-
"/src/detect/test_data/linux-empty-hwcap2-aarch64.auxv"
432-
);
433-
println!("file: {file}");
434-
let v = auxv_from_file(file).unwrap();
435-
println!("HWCAP : 0x{:0x}", v.hwcap);
436-
println!("HWCAP2: 0x{:0x}", v.hwcap2);
437-
assert_eq!(AtHwcap::from(v), baseline_hwcaps());
438-
}
439-
#[test]
440-
fn linux_no_hwcap2_aarch64() {
441-
let file = concat!(
442-
env!("CARGO_MANIFEST_DIR"),
443-
"/src/detect/test_data/linux-no-hwcap2-aarch64.auxv"
444-
);
445-
println!("file: {file}");
446-
let v = auxv_from_file(file).unwrap();
447-
println!("HWCAP : 0x{:0x}", v.hwcap);
448-
println!("HWCAP2: 0x{:0x}", v.hwcap2);
449-
assert_eq!(AtHwcap::from(v), baseline_hwcaps());
450-
}
451-
#[test]
452-
fn linux_hwcap2_aarch64() {
453-
let file = concat!(
454-
env!("CARGO_MANIFEST_DIR"),
455-
"/src/detect/test_data/linux-hwcap2-aarch64.auxv"
456-
);
457-
println!("file: {file}");
458-
let v = auxv_from_file(file).unwrap();
459-
println!("HWCAP : 0x{:0x}", v.hwcap);
460-
println!("HWCAP2: 0x{:0x}", v.hwcap2);
461-
assert_eq!(
462-
AtHwcap::from(v),
463-
AtHwcap {
464-
// Some other HWCAP bits.
465-
paca: true,
466-
pacg: true,
467-
// HWCAP2-only bits.
468-
dcpodp: true,
469-
frint: true,
470-
rng: true,
471-
bti: true,
472-
mte: true,
473-
..baseline_hwcaps()
474-
}
475-
);
476-
}
477-
}
478-
}
398+
mod tests;
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
use super::*;
2+
3+
#[cfg(feature = "std_detect_file_io")]
4+
mod auxv_from_file {
5+
use super::auxvec::auxv_from_file;
6+
use super::*;
7+
// The baseline hwcaps used in the (artificial) auxv test files.
8+
fn baseline_hwcaps() -> AtHwcap {
9+
AtHwcap {
10+
fp: true,
11+
asimd: true,
12+
aes: true,
13+
pmull: true,
14+
sha1: true,
15+
sha2: true,
16+
crc32: true,
17+
atomics: true,
18+
fphp: true,
19+
asimdhp: true,
20+
asimdrdm: true,
21+
lrcpc: true,
22+
dcpop: true,
23+
asimddp: true,
24+
ssbs: true,
25+
..AtHwcap::default()
26+
}
27+
}
28+
29+
#[test]
30+
fn linux_empty_hwcap2_aarch64() {
31+
let file = concat!(
32+
env!("CARGO_MANIFEST_DIR"),
33+
"/src/detect/test_data/linux-empty-hwcap2-aarch64.auxv"
34+
);
35+
println!("file: {file}");
36+
let v = auxv_from_file(file).unwrap();
37+
println!("HWCAP : 0x{:0x}", v.hwcap);
38+
println!("HWCAP2: 0x{:0x}", v.hwcap2);
39+
assert_eq!(AtHwcap::from(v), baseline_hwcaps());
40+
}
41+
#[test]
42+
fn linux_no_hwcap2_aarch64() {
43+
let file = concat!(
44+
env!("CARGO_MANIFEST_DIR"),
45+
"/src/detect/test_data/linux-no-hwcap2-aarch64.auxv"
46+
);
47+
println!("file: {file}");
48+
let v = auxv_from_file(file).unwrap();
49+
println!("HWCAP : 0x{:0x}", v.hwcap);
50+
println!("HWCAP2: 0x{:0x}", v.hwcap2);
51+
assert_eq!(AtHwcap::from(v), baseline_hwcaps());
52+
}
53+
#[test]
54+
fn linux_hwcap2_aarch64() {
55+
let file =
56+
concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-hwcap2-aarch64.auxv");
57+
println!("file: {file}");
58+
let v = auxv_from_file(file).unwrap();
59+
println!("HWCAP : 0x{:0x}", v.hwcap);
60+
println!("HWCAP2: 0x{:0x}", v.hwcap2);
61+
assert_eq!(
62+
AtHwcap::from(v),
63+
AtHwcap {
64+
// Some other HWCAP bits.
65+
paca: true,
66+
pacg: true,
67+
// HWCAP2-only bits.
68+
dcpodp: true,
69+
frint: true,
70+
rng: true,
71+
bti: true,
72+
mte: true,
73+
..baseline_hwcaps()
74+
}
75+
);
76+
}
77+
}

library/std_detect/src/detect/os/linux/auxvec.rs

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)