Unit testing patterns for microcontroller C code

后端 未结 4 1257
隐瞒了意图╮
隐瞒了意图╮ 2020-12-24 08:03

Although there are plenty of unit test frameworks that support C, I\'m a little stumped on how to write unit tests for micro controller code (PIC in my case, but I think the

4条回答
  •  孤独总比滥情好
    2020-12-24 08:50

    One approach to this might be to use an emulator. I've been working on an AVR emulator and one of the ideas for using it is indeed to unit test code. The emulator implements the CPU and registers, interrupts and various peripherals, and (in my case) bytes written to the emulated UART go to the regular stdout of the emulator. In this way, unit test code can run in the emulator and write its test results to the console.

    Of course, one must also ensure that the emulator is correctly implementing the behaviour of the real CPU, otherwise the unit tests on top of that can't be trusted.

提交回复
热议问题