diff options
author | iximeow <me@iximeow.net> | 2021-09-26 00:40:03 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2021-09-26 00:40:03 -0700 |
commit | 23bd0b37482a127c8f954ce7e068a507b9c1e09e (patch) | |
tree | 634a991f40463f9a1c50b75f5cf4b5ba6e4ef7c0 /test | |
parent | 7fee2c5dafb84ee93ddb6a8f582e99d445c82677 (diff) |
fix unimplemented code paths panicking as unreachable
only in a64 decoding really; there wasn't an "Incomplete" error at the time, but now there is.
Diffstat (limited to 'test')
-rw-r--r-- | test/armv8/a64.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/armv8/a64.rs b/test/armv8/a64.rs index 35a255d..6dd9d9b 100644 --- a/test/armv8/a64.rs +++ b/test/armv8/a64.rs @@ -1,5 +1,6 @@ use yaxpeax_arch::{Arch, Decoder, LengthedInstruction}; use yaxpeax_arm::armv8::a64::{ARMv8, Instruction, Operand, Opcode, SizeCode, ShiftStyle}; +use yaxpeax_arm::armv8::a64::DecodeError; fn test_decode(data: [u8; 4], expected: Instruction) { let mut reader = yaxpeax_arch::U8Reader::new(&data[..]); @@ -12,6 +13,17 @@ fn test_decode(data: [u8; 4], expected: Instruction) { ); } +fn test_err(data: [u8; 4], err: DecodeError) { + let mut reader = yaxpeax_arch::U8Reader::new(&data[..]); + let result = <ARMv8 as Arch>::Decoder::default().decode(&mut reader); + assert_eq!( + result, Err(err), + "expected IncompleteDecoder error for {:02x}{:02x}{:02x}{:02x}:\n decoded: {:?}\n", + data[0], data[1], data[2], data[3], + result, + ); +} + fn test_display(data: [u8; 4], expected: &'static str) { let mut reader = yaxpeax_arch::U8Reader::new(&data[..]); let instr = <ARMv8 as Arch>::Decoder::default().decode(&mut reader).unwrap(); @@ -26,6 +38,13 @@ fn test_display(data: [u8; 4], expected: &'static str) { } #[test] +fn test_neon() { + // currently, NEON is incompletely implemented in yaxpeax-arm. + test_err([0x00, 0x01, 0x27, 0x1e], DecodeError::IncompleteDecoder); + test_display([0xe0, 0x03, 0x13, 0xaa], "mov x0, x19"); +} + +#[test] fn test_display_misc() { test_display( [0xc0, 0x03, 0x5f, 0xd6], |