Introduction
Before actually setting up HIL in your repository, it's important to understand the concepts and terminology. HIL stands for "hardware in the loop" and it refers to a type of testing where actual hardware is used to execute tests. This makes it different from unit testing, in which the tests are executed on a host machine. HIL test are incredibly useful because they allow you to test the software on the real-world hardware, using real-world scenarios to verify product functionality.
Want to jump in?
Want to skip the in-depth info and get your hands dirty? Set up a HIL system for youself using the HIL Quick start guide!
Architecture
The HIL system consists of three main components: The test launcher, the EmbedOps platform, and the HIL setup, which includes a gateway and the Device Under Test (DUT). When the test launcher starts a test run, it packages up the tests along with any support files and sends the whole package to the EmbedOps servers. The servers then find a suitable gateway device that is connected to your project and sends the package to it. The gateway unpacks all of the tests and support files and executes the test run. During testing, any log text or results files are sent in real time all the way back to the test launcher. In this way, the EmbedOps servers act as a middle-man and require no direct interaction with the user. Below is an example with a developer triggering the test launcher manually with EmbedOps CLI.
Hardware
The simplest form of a HIL setup is a gateway connected to the internet, and the device-under-test (DUT). An example HIL setup can be seen below, the HIL that the Quick Start has you setup. In it, the raspberry pi is a Gateway, talking with the EmbedOps Platform and the CLI. It's connected with a USB to the DUT, a nordic nrf5340 dev kit, which runs your custom firmware image.
If you don't have hardware, you can purchase a kit on DigiKey that includes everything you need.
Just because a Gateway+DUT is the simplest HIL setup, doesn't mean it's the only setup. A HIL setup can also include other hardware used to test or manipulate the DUT. For example, if you have a Nordic Power Profiler Kit II, you can add it to your HIL setup and create a test to do current measurements. Follow our PPK2 Example to set that up yourself, or browse the other examples to see what else our HIL can connect to!
Use of PyTest
EmbedOps HIL uses Python and Pytest as the main mechanism for writing tests. The pytest framework makes it easy to write small, readable tests, and can scale to support complex functional testing for applications and libraries. The HIL comes with a custom HIL SDK that contains a number of interfaces to interact with other hardware attached to the gateway and DUT. These interface classes include BLE, GPIO, JTAG, and more. There are even interfaces for specific vendor APIs from companies like Nordic.
There are no special instructions or steps needed to use the HIL SDK in your project. The hil_sdk
folder is simply a Python package and can be used in your code like any other python package (see the examples).
Import statements will begin with from hil_sdk import
. The files in the SDK are part of your repository just
like the rest of your HIL tests, and can be removed or modified to fit your specific needs.