Skip to content

Commit af47efb

Browse files
xusheng6claude
andcommitted
emulator: add a per-instruction LLIL test suite
Addresses review feedback that every LLIL instruction the emulator implements should have at least one unit test. Adds emulator_il_test.py, which builds LLIL directly with LowLevelILFunction (rather than lifting assembly) so each of the 88 operations the emulator handles is exercised in isolation: constants, register read/write and splits, the full arithmetic/logic/shift/rotate/compare/bit families, the double-precision multiply and divide/modulo ops, memory and stack, flags, control flow (goto/if/jump/call/ret/syscall/...), and the nop/trap/undef/unimpl/ intrinsic specials. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 84abd97 commit af47efb

2 files changed

Lines changed: 462 additions & 6 deletions

File tree

plugins/emulator/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,19 @@ The resulting `emulatorcore` plugin is written to `build/out/plugins/`.
4242

4343
## Testing
4444

45-
The Python test suite is self-contained — it assembles tiny `BinaryView`s from raw
46-
machine code rather than shipping test binaries — so it runs headless against any
47-
Binary Ninja install that has the emulator plugin:
45+
The Python test suite is self-contained — it runs headless against any Binary Ninja
46+
install that has the emulator plugin. There are two files:
47+
48+
- [`test/emulator_test.py`](test/emulator_test.py) — end-to-end behaviour, assembling
49+
tiny `BinaryView`s from raw machine code and emulating the lifted LLIL.
50+
- [`test/emulator_il_test.py`](test/emulator_il_test.py) — per-instruction coverage,
51+
building LLIL directly so that every LLIL operation the emulator implements is
52+
exercised in isolation by at least one test.
4853

4954
```sh
50-
PYTHONPATH=<bn install>/python python3 -m pytest test/emulator_test.py
51-
# or, without pytest:
52-
PYTHONPATH=<bn install>/python python3 test/emulator_test.py
55+
PYTHONPATH=<bn install>/python python3 -m pytest test/
56+
# or a single file, without pytest:
57+
PYTHONPATH=<bn install>/python python3 test/emulator_il_test.py
5358
```
5459

5560
## Support status

0 commit comments

Comments
 (0)