Zephyr includes a test runner app called Twister. It has a dizzying number of features, and recently I wrote a script to configure the tool for my most-used operation: cycle testing on embedded devices.
Twister is the test runner tool built into Zephyr RTOS. At Golioth we use it extensively for our Hardware-in-the-Loop testing. I also use it locally for device testing. However, it can be a pain to set up environment variables and remember the test syntax.
A couple of weeks ago I wrote a small helper script to assist in cycle testing. It configures everything, calls Twister, and counts the successes.
Our pytest file for that sample looks for a number of key values to be present as environment variables so I added two blocks to this file to set that all up, commenting or uncommenting for the device under test.
I run this from the root of the Zephyr install. The first Twister command builds the firmware. The --prep-artifacts-for-testing flag saves only the binaries and other files necessary to flash a device into a twister-out directory. I’ll explain the other flags later in this post.