diff options
| author | iximeow <me@iximeow.net> | 2026-07-26 17:56:26 +0000 |
|---|---|---|
| committer | iximeow <me@iximeow.net> | 2026-07-28 07:28:15 +0000 |
| commit | 9b3c56c0e62c3d1c27ffef4b8021663798b73ca7 (patch) | |
| tree | 212b04bd20e3a1b1ec1e9e2296986389b70ef31d /tests/armv7/thumb.rs | |
| parent | 019920be5aa0b3b129a4ecf3bc31c14fddf34eff (diff) | |
thumb: when nonconforming, allow it/cond=1111 like capstone
Diffstat (limited to 'tests/armv7/thumb.rs')
| -rw-r--r-- | tests/armv7/thumb.rs | 22 |
1 files changed, 20 insertions, 2 deletions
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() { |
