joeylib2/scripts/check-serial.sh

26 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
# check-serial.sh - Host-cc harness for the shared serial gate/normalize layer
# (src/core/serial.c). Compiles it with a loopback mock HAL (tests/host/
# serialHost.c) and runs the open/close/gate/normalize/read/write checks.
#
# The BLANK platform block registers no JL_HAS_SERIAL_* (serial is an opt-in
# add-on with no generic hardware), so this passes every serial op flag on the
# command line to make port.h route jlpSerial* to the mock instead of the
# generic no-op. Exits nonzero on any failed check, so it is a CI gate.
set -euo pipefail
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
cc=${CC:-cc}
work=$(mktemp -d -t joeylib-serial.XXXXXX)
trap 'rm -rf "$work"' EXIT
cd "$repo"
"$cc" -DJOEYLIB_PLATFORM_BLANK \
-DJL_HAS_SERIAL_OPEN -DJL_HAS_SERIAL_CLOSE -DJL_HAS_SERIAL_POLL \
-DJL_HAS_SERIAL_READ -DJL_HAS_SERIAL_WRITE -DJL_HAS_SERIAL_AVAILABLE \
-DJL_HAS_SERIAL_FLUSH \
-Iinclude -Iinclude/joey -Isrc/core -Wall -Wextra \
src/core/serial.c tests/host/serialHost.c \
-o "$work/serialHost"
"$work/serialHost"