about summary refs log tree commit diff
path: root/library/std_detect/src/detect/os/linux/aarch64/tests.rs
blob: a3562f2fd936265e4eee58c50f5168089496bba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use super::*;

#[cfg(feature = "std_detect_file_io")]
mod auxv_from_file {
    use super::auxvec::auxv_from_file;
    use super::*;
    // The baseline hwcaps used in the (artificial) auxv test files.
    fn baseline_hwcaps() -> AtHwcap {
        AtHwcap {
            fp: true,
            asimd: true,
            aes: true,
            pmull: true,
            sha1: true,
            sha2: true,
            crc32: true,
            atomics: true,
            fphp: true,
            asimdhp: true,
            asimdrdm: true,
            lrcpc: true,
            dcpop: true,
            asimddp: true,
            ssbs: true,
            ..AtHwcap::default()
        }
    }

    #[test]
    fn linux_empty_hwcap2_aarch64() {
        let file = concat!(
            env!("CARGO_MANIFEST_DIR"),
            "/src/detect/test_data/linux-empty-hwcap2-aarch64.auxv"
        );
        println!("file: {file}");
        let v = auxv_from_file(file).unwrap();
        println!("HWCAP : 0x{:0x}", v.hwcap);
        println!("HWCAP2: 0x{:0x}", v.hwcap2);
        assert_eq!(AtHwcap::from(v), baseline_hwcaps());
    }
    #[test]
    fn linux_no_hwcap2_aarch64() {
        let file = concat!(
            env!("CARGO_MANIFEST_DIR"),
            "/src/detect/test_data/linux-no-hwcap2-aarch64.auxv"
        );
        println!("file: {file}");
        let v = auxv_from_file(file).unwrap();
        println!("HWCAP : 0x{:0x}", v.hwcap);
        println!("HWCAP2: 0x{:0x}", v.hwcap2);
        assert_eq!(AtHwcap::from(v), baseline_hwcaps());
    }
    #[test]
    fn linux_hwcap2_aarch64() {
        let file =
            concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-hwcap2-aarch64.auxv");
        println!("file: {file}");
        let v = auxv_from_file(file).unwrap();
        println!("HWCAP : 0x{:0x}", v.hwcap);
        println!("HWCAP2: 0x{:0x}", v.hwcap2);
        assert_eq!(
            AtHwcap::from(v),
            AtHwcap {
                // Some other HWCAP bits.
                paca: true,
                pacg: true,
                // HWCAP2-only bits.
                dcpodp: true,
                frint: true,
                rng: true,
                bti: true,
                mte: true,
                ..baseline_hwcaps()
            }
        );
    }
}