unicorn
unicorn copied to clipboard
rust-tests: Some RISC-V emulation tests
Thanks for creating Unicorn! I've been using it as part of an emulator for the syscall ABI of a toy RISC-V operating system.
I started working on this because I was seeing some strange behavior in my own program (invalid invalid instruction hook not being called) and so wanted to see if I could reproduce it without all of my code in play.
Now there is a happy-path test of successfully executing a single instruction, along with two different ways of hooking an invalid instruction (using either general interrupt hook or invalid instruction hook) and also using general interrupt hook to handle an ecall instruction.
As currently written the emulate_riscv64_invalid_insn_hook
test fails, because the hook doesn't seem to run at all and so the emu_start
function returns Err(UC_EXCEPTION)
. I'm not sure whether that's my own bug or if something is not working correctly in the main Unicorn code. :thinking: I've opened this PR as a draft in case someone can identify a mistake I could fix to make the instruction hook test work, in which case I'd propose to add these tests just to help reduce the risk of regressions in the RISC-V platform support.