How to perform unit testing of embedded C code in Code Compose Studio (CCS) for MSP430G2553 target board?


There are several good unit test tools available for PC development. Unit testing on an embedded system, however, presents some unique issues. For instance, typically, a unit test is something that is run automatically after a successful build of changes that have been submitted to the version control system. This is most easily coordinated on a development machine rather than an embedded target such as an MSP430 using a cross compiler. Infrastructure for loading and executing each unit test on the target platform is something that has to be customized for each target platform which is extremely expensive time wise.

Another challenge with embedded systems is they often do not have basic reporting mechanisms. If you are developing a coffee maker, it is unlikely to have a stdio or stderr stream (much less any communications port) to report any results from the unit tests.

The best approach I have seen is to use a unit test framework on the development system, which is often a different compiler. This is not a perfect solution since there can be subtle differences in implementations between compilers, but still much better than no unit tests at all. A book that may be helpful is Test Driven Development for Embedded C by James Grenning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.