Automating Embedded Testing: Using Ceedling With Lantern

Ryan Torvik - January 13, 2025 - 5 minute read

Tulip Tree Technology

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:

  1. Write unit tests.
  2. Run them on the ARMv4 emulator.
  3. 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:

./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:

  1. place the ceedling-example/project.yml file into your source folder similarly to how the run-ceedling-example does with the temp-sensor example

  2. Navigate 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!

Previous Post

Tulip Tree Technology
Learn Deep | Dream Big

© 2024 Tulip Tree Technology