Site icon Cove Mountain Software

Introducing CppUTest For SST

CppUTest for SST (cpputest-for-sst) is a host-PC unit testing library for well-formed Super-Simple-Tasker (SST) Tasks. The purpose is to enable rapid TDD of SST-based firmware on a host PC.

A sister repository, cpputest-for-sst-examples, shows how to pull the library into a CMake project and how to unit test a realistic SST Task. Both repositories depend on Quantum Leaps’ Super-Simple-Tasker (SST).

If you have already used cpputest-for-qpcpp, cpputest-for-qpc, or cpputest-for-freertos, this will feel familiar. Same overall goals and feel, but targetting the SST kernel and associated Tasks instead.

Why SST, and why a test port?

SST is an event-driven, priority-based kernel for creating firmware. Tasks are run-to-completion and non-blocking. That execution model matches the active object pattern I have recommended for years: one thread of control, one incoming event queue, and behavior that runs to completion when an event arrives.

So what is the benefit of a host-PC SST port? Easier TDD. Module privates stay private. How?

Take a look at timers. If a Task uses an SST::TimeEvt for periodic behavior and we want host-PC unit tests, the options include:

What the library actually provides

The library is C++ only, matching the C++ edition of SST. It is not a collection of empty stubs. The Task-under-test talks to SST. The test talks to a small control API that decides when SST is allowed to run.

The important pieces:

The examples repository

cpputest-for-sst-examples is a top-level CMake project that:

That service is intentionally familiar. It locks and unlocks hardware, runs a self-test and returns to history, and polls communication status on a timer. The tests cover the happy path, the silent no-op path, self-test pass/fail, and timer edge cases. If you have read “Unit Testing of Active Objects and State Machines,” it will likely be familar to you.

SST, QP, and when to look elsewhere

SST is deliberately small. If the SST approach is too simple for your firmware project, look at QP/C or QP/C++ and the associated cpputest-for-qp* libraries.

My generally thinking at this time: if a project is complex enough to need preemptive tasks, then look to QP instead. Exceptions apply.

If this project and its related projects inspire your team to select a QP framework for commercial use, please note “Matthew Eshleman” or “Cove Mountain Software” in the referral field when acquiring a commercial license from Quantum Leaps. Referrals encourage and support efforts like this. Thank you.

Licensing

cpputest-for-sst and the examples project are MIT licensed. SST itself is also MIT. SST, CppUTest, and any other third-party code keep their own licenses.

Where to start

I hope this library proves useful to firmware teams that chose SST and still want a fast TDD loop. Start here:

Related reading:

Exit mobile version