Creating compiler tests

I’m writing a subset of C compiler that generates AVR assembly. I’m debugging the generated assembly using PlatformIO with “debug_tool = simavr”. I’d also like to write compiler tests though, which I think requires running the assembly from a testing script and then get the final register states for the script to check. Is this possible with PlatformIO? Is there a better way of doing this?

I think simavr will still be your best bet. With that simulator, you can just set a breakpoint after some code’s execution and grab the state of processor and compare it. Not sure though how you would integrate executing these tests with PlatformIO though, best to have them as a seperate script maybe?

There’s some examples with using libsimavr to load a compiled .elf file and run it:

1 Like