aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/armv7.rs5
-rw-r--r--test/armv7/thumb.rs5
-rw-r--r--test/armv8/a64.rs7
-rw-r--r--test/test.rs41
4 files changed, 58 insertions, 0 deletions
diff --git a/test/armv7.rs b/test/armv7.rs
index 7feb774..a60b50a 100644
--- a/test/armv7.rs
+++ b/test/armv7.rs
@@ -106,6 +106,11 @@ fn test_display(data: [u8; 4], expected: &'static str) {
}
#[test]
+fn test_unpredictable_instructions() {
+ test_invalid([0x00, 0x02, 0x08, 0x01]); // msr with invalid machine register
+}
+
+#[test]
fn test_decode_str_ldr() {
test_decode(
[0x24, 0xc0, 0x9f, 0xe5],
diff --git a/test/armv7/thumb.rs b/test/armv7/thumb.rs
index fafc65c..c74da37 100644
--- a/test/armv7/thumb.rs
+++ b/test/armv7/thumb.rs
@@ -77,6 +77,11 @@ fn test_display(data: &[u8], expected: &'static str) {
}
#[test]
+fn test_unpredictable_instructions() {
+ test_invalid(&[0x80, 0xfa, 0x40, 0x00]);
+}
+
+#[test]
fn test_decode_add_cases() {
test_display(
&[0x01, 0x44],
diff --git a/test/armv8/a64.rs b/test/armv8/a64.rs
index 6dd9d9b..0e25c93 100644
--- a/test/armv8/a64.rs
+++ b/test/armv8/a64.rs
@@ -45,6 +45,13 @@ fn test_neon() {
}
#[test]
+fn test_unpredictable() {
+ // could be stx/ldx but Lo1 is `x1` and invalid.
+ test_err([0x00, 0x00, 0x20, 0x08], DecodeError::InvalidOpcode);
+ test_err([0x00, 0xfc, 0x00, 0x12], DecodeError::InvalidOperand);
+}
+
+#[test]
fn test_display_misc() {
test_display(
[0xc0, 0x03, 0x5f, 0xd6],
diff --git a/test/test.rs b/test/test.rs
index fcf680a..b333fc1 100644
--- a/test/test.rs
+++ b/test/test.rs
@@ -7,3 +7,44 @@ extern crate yaxpeax_arm;
mod armv7;
mod armv8;
+
+use yaxpeax_arch::{Arch, Decoder, Reader, U8Reader};
+use std::fmt;
+
+#[test]
+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();
+ }
+ }
+}
+#[test]
+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();
+ }
+ }
+}
+#[test]
+fn test_armv8_does_not_panic() {
+ let armv8 = <yaxpeax_arm::armv8::a64::ARMv8 as Arch>::Decoder::default();
+
+ for i in 0..=u32::MAX {
+ let bytes = i.to_le_bytes();
+ let res = armv8.decode(&mut U8Reader::new(&bytes));
+ if let Ok(instr) = res {
+ let s = instr.to_string();
+ }
+ }
+}