sysprog21 / semu

A minimalist RISC-V system emulator capable of running Linux kernel
MIT License
251 stars 47 forks source link

Fix the pass condition of riscv-tests #8

Closed gagachang closed 2 years ago

gagachang commented 2 years ago

Previous code only checks if the register a0 equals zero or not to determine if the test is passed. But there will be a bug if semu has not implemented the tested instruction yet. Semu always regards this kind of instruction as an illegal instruction, and further triggers an exception. If there is an exception, the riscv-tests will set the "tohost" variable other than 1, and stuck in an infinite loop. Since the test is not finished, the value of a0 is meaningless.

This patch fixes the pass condition that semu checks not only a0, but also the tohost variable, to determine the result of the test.