Skip to the content.
« Previous Index Next »

Firmware Coding Standard — Testing & CI Gates (FreeRTOS)

1) Purpose

Define rules for testing FreeRTOS-based firmware and enforcing automated CI checks. Ensure regressions are caught early, code quality remains high, and releases are provably stable.


2) Principles


3) Levels of Testing


4) CI Gates

Every PR/build must pass these gates before merge/release:

  1. Build & Lint

    • Build for all targets/configs.
    • Lint (MISRA-C or equivalent ruleset).
    • Check for forbidden APIs (malloc, printf, non-ISR-safe RTOS calls).
  2. Unit Test Execution

    • Run on PC-hosted test framework.
    • Must achieve coverage target (e.g., 80% line coverage).
  3. Static Analysis

    • Run tools like Cppcheck, Clang Static Analyzer.
    • No unreviewed warnings allowed.
  4. Resource Budget Checks

    • Enforce max flash/RAM usage.
    • Verify stack sizes and heap usage.
  5. Runtime Sim Tests

    • Run app in QEMU/simulator with scripted events.
    • Verify system boots, tasks start, watchdog kicks.
  6. HIL Smoke Tests (nightly or gated):

    • Deploy to real hardware, run basic comms, logging, and OTA cycle.
    • Capture power consumption, jitter, reset cause logs.

5) Fault Injection Testing


6) Code Coverage & Metrics


7) Anti-Patterns


8) Review Checklist (Testing/CI)


9) CI/Lint Gates


10) Example CI Pipeline

stages:
  - build
  - lint
  - unit-test
  - analysis
  - sim
  - hil

build:
  script: make all

lint:
  script: make lint

unit-test:
  script: make test

analysis:
  script: make static-analysis

sim:
  script: make run-sim

hil:
  script: make hil-smoke
  when: nightly

« Previous Index Next »