Test Driven Development with ChibiOS simulator
Posted: Tue Jun 04, 2019 4:49 am
Lately, I've been reading the book about TDD by James Grenning. Has anyone implemented dual-targeting for TDD on the ChibiOS simulator?
I was thinking of trying it out, but some of the immediate complications of dual targeting are already in my way:
- Linking things like chprintf() to target my PC's standard output
- Simulating asynchronous events, such as interrupts in the RT-Posix simulator is not obvious
Suppose I want to write an events queue module for my application. The TDD method would have me write a simple test, then write code until the test passes, and then repeat until the driver is done (along with a full suite of tests).
I thought I could just do this with a compile-download-debug method, by running the tests on my STM32, but the download time is expensive, and feedback from my code changes are therefore slow. James' book argues that dual targeting allows for very quick feedback to your code changes, since your PC immediately builds and runs what you just wrote. Not only that, but that you should be able to test your ENTIRE codebase before ever getting the MCU target to run it on. This would be supremely helpful to developer's productivity.
I'm finding out that chibiOS is a little weird as far as projects go, in that the MCU is still targeted primarily for unit tests. This will be prevent the project from ever integrating into a continuous integration/delivery system, which greatly reduces the time between bugs created to bugs discovered.
Can we consider a way to expand the intent of the simulators already in place? According to this thread: viewtopic.php?f=3&t=4861 the sims are there for regression testing and code coverage.
This would require adding "mock" drivers and devices to the codebase, so that UARTs and SPIs and accelerometers and timers can ALL be easily retargeted to the developer's PC with a single, small change in a makefile.
Anyone have experience in this area? I have little experience developing on full PC platforms, but I love the ChibiOS project - so I want to know how I can help it to "keep up" with how many other projects do development, integration, and testing automatically.
Thoughts anyone?
-T
I was thinking of trying it out, but some of the immediate complications of dual targeting are already in my way:
- Linking things like chprintf() to target my PC's standard output
- Simulating asynchronous events, such as interrupts in the RT-Posix simulator is not obvious
Suppose I want to write an events queue module for my application. The TDD method would have me write a simple test, then write code until the test passes, and then repeat until the driver is done (along with a full suite of tests).
I thought I could just do this with a compile-download-debug method, by running the tests on my STM32, but the download time is expensive, and feedback from my code changes are therefore slow. James' book argues that dual targeting allows for very quick feedback to your code changes, since your PC immediately builds and runs what you just wrote. Not only that, but that you should be able to test your ENTIRE codebase before ever getting the MCU target to run it on. This would be supremely helpful to developer's productivity.
I'm finding out that chibiOS is a little weird as far as projects go, in that the MCU is still targeted primarily for unit tests. This will be prevent the project from ever integrating into a continuous integration/delivery system, which greatly reduces the time between bugs created to bugs discovered.
Can we consider a way to expand the intent of the simulators already in place? According to this thread: viewtopic.php?f=3&t=4861 the sims are there for regression testing and code coverage.
This would require adding "mock" drivers and devices to the codebase, so that UARTs and SPIs and accelerometers and timers can ALL be easily retargeted to the developer's PC with a single, small change in a makefile.
Anyone have experience in this area? I have little experience developing on full PC platforms, but I love the ChibiOS project - so I want to know how I can help it to "keep up" with how many other projects do development, integration, and testing automatically.
Thoughts anyone?
-T