From 23bd0b37482a127c8f954ce7e068a507b9c1e09e Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 26 Sep 2021 00:40:03 -0700 Subject: 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. --- test/armv8/a64.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/armv8') 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 = ::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 = ::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], -- cgit v1.1