Automating Embedded Testing: Using Ceedling With Lantern
Ryan Torvik - January 13, 2025 - 5 minute read
What is Ceedling and Why Use It?
Ceedling is a robust unit testing framework for C projects, designed with embedded systems in mind.
If you haven’t tried Lantern yet, check out our previous blog post to get started. To refresh, Lantern emulates an ARMv4 VirtIO Linux kernel, allowing you to run and test cross-compiled applications in a realistic ARM environment. By integrating Ceedling with Lantern, you can establish a seamless testing workflow:
- Write unit tests.
- Run them on the ARMv4 emulator.
- Debug and validate results efficiently.
Together, Ceedling and Lantern provide a complete solution for testing embedded applications.
Setup
1. Get Latest Version of Lantern
Use the Download
button on the top left of the website and an email with a license key and the complete source code to run lantern will be sent to you.
2. Setup Dev Container
In this example, we are using VS Code as our text editor and dev environment. We need to make a new Docker-in-Docker dev container to create a consistent environment for running Lantern and Ceedling.
Start VS Code, run the Dev Containers: Open Folder in Container...
command from the Command Palette F1
or quick actions Status bar item, and select the extracted Lantern source folder.
Then select Add configuration to workspace
.
Now select Docker-in-Docker
as your container configuration.
Next, select lastest
as your CLI Version and make sure to check Upgrade OS packages
.
Lastly, we need to install ruby for Ceedling to work correctly.
Use Keep Default
options and no optional files in the next dialog boxes.
3. Run Install Script
Inside the development environment, execute the installation script in the bash terminal for Emerson, our emulator. This will prompt you for your licence key that was sent to you by email.
./install
4. Execute Run-Ceedling-Example
The setup script will handle the following:
- Install the ARMv4 cross-compiler required by Lantern.
- Install Ceedling 1.0.0.
- Clone the Ceedling repository to access temp_sensor example project.
- Run tests from the Ceedling example project examples/temp_sensor inside the Lantern emulator.
./run-ceedling-example
This should have run all of the Ceedling tests from the temp_sensor example inside of the Emerson emulator and give the result. As you can see, it takes some time to run all 51 tests through the Emulator!
Using Ceedling and Lantern for Your Own Projects
Going forward, to use Ceedling and Lantern for your own projects:
place the
ceedling-example/project.yml
file into your source folder similarly to how therun-ceedling-example
does with the temp-sensor exampleNavigate into your project folder containing:
- Your ARMv4 cross-compiled code.
- Your Ceedling tests.
- The Ceedling project.yml configuration file.
Run to execute your tests:
ceedling test:all
Check out the Ceedling documentation and examples to see how to integrate your project!
Note: In the ceedling-example project.yml
, we have overwritten all unnecessary compilation phases to ensure the use of the ARMv4 cross-compiler for Lantern. We have also changed the amount of test_threads
to 1 due to docker image constraints.
Conclusion
By combining Ceedling and Lantern, you gain a robust testing solution for embedded applications. Ceedling automates the testing process, while Lantern provides a realistic ARMv4 environment for running and debugging your code. Together, they create a seamless workflow for development and validation.
We encourage you to try this integration with your own projects! For more information or questions, check out:
Tulip Tree Tech Slack | Lantern GitHub | Ceedling GitHub
Happy testing!