#!/usr/bin/env bash # Build and run the firmware's host tests. Exits non-zero on any failure. # # Dependencies: gcc (and libm, which ships with it). Nothing else — no # ESP-IDF, no make required (there is a Makefile, but this script does not # depend on it), no test framework, no package install. # # These tests cover PURE LOGIC ONLY: frame parsing, byte order, compensation # maths, level maths. They do not and cannot verify wiring, timing, or how # the real silicon behaves. See ../README.md "What's verified vs. not". set -euo pipefail cd "$(dirname "$0")" CC="${CC:-gcc}" CFLAGS=(-std=c11 -O1 -g -Wall -Wextra -Werror) BUILD="build" BIN="$BUILD/firmware_tests" if ! command -v "$CC" >/dev/null 2>&1; then echo "run_tests.sh: '$CC' not found; install gcc (or set CC=clang)" >&2 exit 127 fi mkdir -p "$BUILD" echo "== building host tests with $CC ${CFLAGS[*]}" "$CC" "${CFLAGS[@]}" -o "$BIN" \ ../main/rd03e_parse.c \ ../main/bmp280_compensate.c \ ../main/mems_level.c \ test_main.c \ test_rd03e_parse.c \ test_bmp280_compensate.c \ test_mems_level.c \ -lm echo "== running" "./$BIN"