From 9b3c56c0e62c3d1c27ffef4b8021663798b73ca7 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 26 Jul 2026 17:56:26 +0000 Subject: thumb: when nonconforming, allow it/cond=1111 like capstone --- tests/armv7/thumb.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'tests/armv7') diff --git a/tests/armv7/thumb.rs b/tests/armv7/thumb.rs index d9ecda6..c8b0b11 100644 --- a/tests/armv7/thumb.rs +++ b/tests/armv7/thumb.rs @@ -19,8 +19,8 @@ fn test_invalid_under(decoder: &InstDecoder, data: &[u8]) { } #[allow(dead_code)] -fn test_display_under(decoder: &InstDecoder, data: [u8; 4], expected: &'static str) { - let mut reader = yaxpeax_arch::U8Reader::new(&data[..]); +fn test_display_under(decoder: &InstDecoder, data: &[u8], expected: &'static str) { + let mut reader = yaxpeax_arch::U8Reader::new(data); let instr = match decoder.decode(&mut reader) { Err(e) => { panic!("failed to decode {:#x?}: {}", data, e) @@ -76,6 +76,20 @@ fn test_display(data: &[u8], expected: &'static str) { ); } +fn test_nonconforming(data: &[u8], expected: &'static str) { + let conforming = InstDecoder::default_thumb().allow_nonconforming(false); + let nonconforming = InstDecoder::default_thumb().allow_nonconforming(true); + + let mut reader = yaxpeax_arch::U8Reader::new(&data[..]); + let result = conforming.decode(&mut reader); + assert!( + result.is_err(), + "got bad result: {:?} from {:#x?}", result, data + ); + + test_display_under(&nonconforming, data, expected); +} + #[test] fn test_unpredictable_instructions() { test_invalid(&[0x80, 0xfa, 0x40, 0x00]); @@ -1951,6 +1965,10 @@ fn test_decode_it_cases() { &[0xef, 0xbf], "iteee al" ); + test_nonconforming( + &[0xf7, 0xbf], + "ittee al", + ); } #[test] fn test_decode_ldm_16b_cases() { -- cgit v1.1