diff options
author | iximeow <me@iximeow.net> | 2021-09-28 19:48:39 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2021-09-28 19:48:39 -0700 |
commit | ce99ad8e8e5260f3a8bac896e14faf54f0df6c58 (patch) | |
tree | 8daf5ccfd77d27ffaafa915a1e1f6608ce80a105 /test/test.rs | |
parent | 23bd0b37482a127c8f954ce7e068a507b9c1e09e (diff) |
fix various armv8 and armv8 panics that should be Err.
in fact the decoder should _never_ panic. included here are tests that
cover the entire 32-bit instruction space and ensure that decoding and
display do not panic. these tests run uncomfortably slowly (1168s to
decode the 4b "instruction" sequences on my desktop), but verify that
panics are no longer an issue.
Diffstat (limited to 'test/test.rs')
-rw-r--r-- | test/test.rs | 41 |
1 files changed, 41 insertions, 0 deletions
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(); + } + } +} |