Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

We use unit tests to cover virtually all the code that isn't directly interacting with the hardware. There is a tutorial on exactly how and why we do that here, but the gist of it is that it allows us to catch super nitty gritty bugs (like uninitialized variables or overshooting array bounds) way before the software gets uploaded to the aircraft. The unit tests all run locally on your PC, so we are even catching these bugs way before we upload any code to the micro controller.

To do this, we work with the open source "google test" test harness, which google wrote so that they can unit test their own C++ code and decided to release so that the public could make use of it. A test harness is a piece of software that allows us to poke at our code and that gives us a bunch of mechanisms to check that certain conditions are met. Below are the instructions for installing the harness and running the tests.

MacOs:

Prerequisites:

  • Have Cmake installed

Install instructions:

Attached to this page, you will find a file named GtestInstall_Mac.bash. Download it and run it with ./GtestInstall_Mac.bash in whatever directory interests you.


Linux/WSL:

Prerequisites:

  • Have Cmake installed

Install instructions:

Attached to this page, you will find a file named GtestInstall_Linux.bash. Download it and run it with ./GtestInstall_Linux.bash in whatever directory interests you.


Windows:

Prerequisites:

  • Have Cmake installed

  • Have git bash installed

Install instructions:

  1. Install chocolatey

    1. Open the windows PowerShell in admin mode.

    2. Inside it, run:

      Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

      Note that this script has not worked for everyone. If it produces any errors, try running the following instead (from powershell admin):

      iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex

  2. Attached to this page (top right under the three dots then attachements), you will find a file named GtestInstall_Windows.bash. Download it and, from git bash in admin mode (having git bash in admin mode is really important!!!), run it with ./GtestInstall_Windows.bash in whatever directory interests you.

Running the unit tests:

  1.  cd into ZeroPilot-SW\Autopilot

  2. run ./Tools/build.bash -c -t (-c is only needed the first time, or occasionally when you are switching from a regular build to a unitTest build).

  • No labels