Documentation
Onboarding
Getting Started
Power & Battery
Hardware & Components
Build & Assembly
Radio & RF Design
Frequencies & Regulations
Firmware & Software
USB & Connectivity
GPS & Navigation
Morse & Communication
Modes & Operation
Field Operations & Rescue
Building Effectively
Build Variants
Project & Reference
Docs Firmware & Software Unit Testing the Firmware

Unit Testing the Firmware

Edit on GitHub

Testing firmware logic on the host: what can be tested without hardware, the test layout, and what the CI runs.

Unit Testing the Firmware

Most firmware bugs live in pure logic: the Morse encoder, the payload builder, the NMEA parser. Those functions do not need hardware, so they can be tested on a computer, fast, in CI.

What can be tested on the host

ModuleWhat the test checks
Morse encoderCorrect dots/dashes for every letter and digit
Payload builderExact output for given inputs (see Config Payload Format)
NMEA parserField extraction and checksum validation
Config loaderDefaults, version migration, invalid-blob recovery
Coordinate conversionDDM to decimal and back (see Coordinate Conversion)

The test layout

PlatformIO’s unit test framework puts tests next to the code:

CODE
lib/morse/
  morse.c
  test/test_morse.cpp

Run with pio test (see PlatformIO Guide). The tests compile the module for the host, run, and report pass/fail in seconds.

The golden test

The best kind of test for a beacon payload: a golden test. Feed known inputs, assert the exact expected bytes:

CODE
build_payload("SOS", "IK2XYZ", 45.8325, 6.8650)
  == "SOS DE IK2XYZ 45.8325 6.8650"

When the format changes (see Changelog), the golden test changes with it, deliberately, in the same commit.

What CI runs

The CI builds and runs the host tests on every push (see CI/CD). A failing test blocks the merge: that is the point of the pipeline.

What still needs hardware

Timing, radio behavior, GPS acquisition and battery behavior cannot be unit-tested. Those get the bench procedures: Two Beacon Bench Test and Receiver Testing.