blob: 5007464e5df90ef00c543eb27af5903ad28524dd (
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
78
|
// #![feature(test)]
//
// extern crate test;
mod armv7;
mod armv8;
use yaxpeax_arch::{Arch, Decoder, U8Reader};
use std::fmt::Write;
#[test]
#[ignore]
fn test_armv7_does_not_panic() {
let armv7 = <yaxpeax_arm::armv7::ARMv7 as Arch>::Decoder::default();
for i in 0..=u32::MAX {
let bytes = i.to_le_bytes();
let res = armv7.decode(&mut U8Reader::new(&bytes));
if let Ok(instr) = res {
let s = instr.to_string();
drop(s);
}
}
}
#[test]
#[ignore]
fn test_armv7_thumb_does_not_panic() {
let mut armv7_t = <yaxpeax_arm::armv7::ARMv7 as Arch>::Decoder::default();
armv7_t.set_thumb_mode(true);
for i in 0..=u32::MAX {
let bytes = i.to_le_bytes();
let res = armv7_t.decode(&mut U8Reader::new(&bytes));
if let Ok(instr) = res {
let s = instr.to_string();
drop(s);
}
}
}
#[test]
#[ignore]
fn test_armv8_does_not_panic() {
fn test_range(start: u64, end: u64) {
let armv8 = <yaxpeax_arm::armv8::a64::ARMv8 as Arch>::Decoder::default();
let mut instr = <yaxpeax_arm::armv8::a64::ARMv8 as yaxpeax_arch::Arch>::Instruction::default();
let mut s = String::new();
for i in start..=end {
if i & 0x01_ff_ff_ff == 0 {
eprintln!("case {:08x}", i);
}
let i = i as u32;
let bytes = i.to_le_bytes();
let res = armv8.decode_into(&mut instr, &mut U8Reader::new(&bytes));
if let Ok(()) = res {
s.clear();
write!(s, "{}", instr).unwrap();
}
}
}
const NR_THREADS: u64 = 512;
const RANGE_SIZE: u64 = (u32::MAX as u64 + 1) / NR_THREADS;
let mut handles = Vec::new();
for i in 0..NR_THREADS {
let handle = std::thread::spawn(move || test_range(i * RANGE_SIZE, (i + 1) * RANGE_SIZE));
handles.push(handle);
}
while let Some(handle) = handles.pop() {
handle.join().unwrap();
}
}
|