PX4 is safety-critical software — a bug in flight control code can crash a vehicle. Every contribution must include adequate testing. This page explains the testing tools available, how to run them locally, and what the CI pipeline checks before a pull request can be merged.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PX4/PX4-Autopilot/llms.txt
Use this file to discover all available pages before exploring further.
Types of tests
| Test type | When to use | How to run |
|---|---|---|
| Unit tests (gtest) | Module-level logic, math, parsing, state machines | make tests |
| SITL integration tests | Flight behavior, failsafes, missions, mode changes | test/mavsdk_tests/ |
| Bench tests / flight logs | Hardware-dependent changes that can’t run in SITL | Upload to Flight Review |
Running tests locally
Always run tests locally before pushing. CI runs the same checks, so catching failures early saves time.Unit tests
PX4 uses GoogleTest (gtest) as its unit test framework. Unit tests live alongside the modules they test, typically in atest/ subdirectory or a *_test.cpp file next to the module source.
Running unit tests
Writing a unit test
CMakeLists.txt:
New features must include unit tests that exercise the new logic where it is practical to do so. Hardware-dependent code that cannot be tested in simulation should include flight log evidence instead.
SITL integration tests
Software-in-the-Loop (SITL) integration tests run the full PX4 stack in simulation using Gazebo. They test end-to-end flight behavior including missions, failsafes, and mode transitions.Running SITL tests
- Full SITL test suite
- MAVSDK integration tests
test/mavsdk_tests/ covers a specific flight scenario.
Hardware-in-the-loop tests
For changes that require real hardware (sensor drivers, actuator outputs, board-specific code), run bench tests or actual flight tests and upload the resulting log files:Flash and fly
Build and flash the firmware to your hardware target, then perform the relevant test flight or bench test.
Upload to Flight Review
Upload the log to logs.px4.io and copy the resulting URL.
CI pipeline overview
PX4 uses GitHub Actions for continuous integration. Every pull request triggers the full CI pipeline automatically.What CI checks
Format check
Runs
make check_format to verify all changed C/C++ files are correctly formatted. Failures block the PR.Build matrix
Builds PX4 for a matrix of target boards and configurations to catch compilation errors across platforms.
CI workflow files
CI configuration lives in.github/workflows/. Use the ci scope when committing changes to workflow files:
All CI checks must pass before a maintainer can approve and merge your pull request. If a check fails on infrastructure issues (flaky test, network timeout), you can re-run the specific job from the GitHub Actions UI.
Pre-PR checklist
Before opening a pull request, confirm you have completed the following:Prepare test evidence
For hardware changes, upload your flight log to Flight Review and note the URL to include in your PR description.