Skip to content

Test GISNav

This page describes how you run some of the test suites included with GISNav. Tests can be run locally which is usefule for development, or in a container which is useful as part of a CI pipeline.

Prerequisites

The prerequisites depend on whether you are running a local installation or using a Docker container.

Local

These instructions assume you have installed GISNav locally.

Development dependencies required

Remember to also install the development dependencies as instructed in the Python dependencies section.

Docker

Follow the Docker Compose deployment instructions to build the gisnav Docker image and to create the container.

Static analysis

Static analysis runs the pre-commit configuration in the repository root directory on all files, not just the ones staged for commit:

bash
cd ~/colcon_ws/src/gisnav
make test-static
bash
cd ~/colcon_ws/src/gisnav/docker
docker compose -p gisnav run gisnav make test-static

Launch tests

Launch tests using the ROS launch_testing package are provided for smoke testing launch files for common launch configurations in the test.launch package. They are quick tests that would typically reveal basic issues with the nodes, like a node not starting properly or crashing soon after startup.

bash
cd ~/colcon_ws/src/gisnav
make test-launch
bash
cd ~/colcon_ws/src/gisnav/docker
docker compose -p gisnav run gisnav make test-launch

You can also try running only specific launch tests with commands like below:

bash
cd ~/colcon_ws/src/gisnav
launch_test src/gisnav/gisnav/test/launch/test_default_launch.py
bash
cd ~/colcon_ws/src/gisnav/docker
docker compose -p gisnav run gisnav launch_test src/gisnav/gisnav/test/launch/test_default_launch.py

Unit tests

Todo

Implement a basic set of unit tests that is useful.

SITL tests

The SITL tests are powerful automated test suites that simulate GISNav in an end-to-end loop with the autopilot inside a simulated world with simulated but realistic sensor data.

Additional prerequisites

The SITL tests require some additional supporting Docker Compose services to be built and created:

bash
cd ~/colcon_ws/src/gisnav/docker
docker compose -p gisnav build px4
docker compose -p gisnav create px4
make expose-xhost

Run SITL tests

SITL tests are under the gisnav/test/sitl folder. Use the below commands to run the SITL test:

bash
cd ~/colcon_ws/src/gisnav/gisnav
make test-sitl
bash
cd ~/colcon_ws/src/gisnav/docker
docker compose -p gisnav run gisnav make test-sitl

SITL tests not included in CI

The SITL tests are not run in CI since they would realistically require a GPU-enabled runner, which is inconvenient.

Flight log analysis

The flight logs generated by the SITL tests can be analyzed e.g. with the help of the example code snippets in the Jupyter notebooks in the test/ulog_analysis folder. You must first start jupyter-notebook:

bash
cd ~/colcon_ws/src/gisnav/gisnav/test/sitl/ulog_analysis
jupyter-notebook

The notebook documents the analysis and displays the results. Download the example ULog files from Google Drive here.

Code coverage reports

To generate and inspect code coverage you can use coverage.py. See the official instructions on how to configure what source files to measure.

Use the below command to run and inspect a code coverage report for the launch tests for the default launch configuration:

bash
cd ~/colcon_ws
python3 -m coverage run --branch --include *gisnav* src/gisnav/gisnav/test/launch/test_default_launch.py
python3 -m coverage report

Released under the MIT License.