Northeastern-Electric-Racing / Cerberus

Our FreeRTOS-based vehicle control application
1 stars 0 forks source link

Unit testing framework #69

Closed nwdepatie closed 11 months ago

nwdepatie commented 11 months ago

This PR is adding in Unity, a lightweight unit test framework for C, into our codebase. This should allow developers to easily unit test specific pieces of their code for edge cases. This will also be fairly useful for creating and tuning algorithms. This is in addition to Renode, where Renode will be used to test code on virtual hardware. I think the goal is to build these all into a single test pipeline that developers can just run that will run:

  1. Simple Unity tests
  2. Renode emulation on platform alone
  3. Renode integration test for compatibility between codebases

Hopefully this will ensure that the code that we deploy to the car is fairly robust, already. We can then integrate them into CI for GitHub Actions to have an incredibly robust testing pipeline

NOTE: This does not fully work yet, we need to figure out the best way of mocking drivers. It might boil down to just mocking a bunch of data types which would be gross but would work. Driver mocks might be useful to put into Embedded-Base if we go down that route

To actually run the tests, you run make test in the docker container and it will run through a bunch of tests for you by automatically running the compiled testing binary