Skip to content

Commit 991acaf

Browse files
committed
Move tests around to appease tidy
1 parent bb65eee commit 991acaf

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
@@ -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

Comments
 (0)