- board: detect cuaU* serial ports in fallback scanner, filter .init/.lock nodes - board: fall through to OS scan when arduino-cli returns empty (serial-discovery uses unsupported Linux syscalls on FreeBSD) - board: recognize cuaU* port names as USB in is_usb() - upload.sh: fix silent exit under set -euo pipefail when vid_pid grep finds nothing (|| true on LOCAL_PORT and LOCAL_VID_PID greps) - upload.sh: add cuaU to auto-detect port pattern - doctor: detect dialer and operator group membership, offer --fix for both - doctor: detect avr-size installed but not on PATH, offer --fix to add to shell rc file via detect_shell_rc() - doctor: context-aware hardware section (suppress misleading messages when groups not yet applied) - doctor: FreeBSD-specific troubleshooting hints throughout - devices: suppress arduino-cli board detection section on FreeBSD (broken due to serial-discovery syscall issues) - devices: always show USB hub tip on FreeBSD - devices: FreeBSD-specific troubleshooting checklist with sequential numbering on all platforms
84 lines
2.2 KiB
Bash
84 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# run_tests.sh -- Build and run host-side unit tests
|
|
#
|
|
# Usage:
|
|
# ./test/run_tests.sh Build and run all tests
|
|
# ./test/run_tests.sh --clean Clean rebuild
|
|
# ./test/run_tests.sh --verbose Verbose test output
|
|
#
|
|
# Prerequisites:
|
|
# cmake >= 3.14, g++ or clang++, git (for fetching gtest)
|
|
#
|
|
# First run will download Google Test (~30 seconds).
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
BUILD_DIR="$SCRIPT_DIR/build"
|
|
|
|
# Portable CPU count -- BSD make requires a number after -j, GNU make does not
|
|
cpu_count() {
|
|
if command -v nproc &>/dev/null; then
|
|
nproc
|
|
elif command -v sysctl &>/dev/null; then
|
|
sysctl -n hw.ncpu
|
|
else
|
|
echo 4
|
|
fi
|
|
}
|
|
|
|
# Color output
|
|
if [[ -t 1 ]]; then
|
|
RED=$'\033[0;31m'; GRN=$'\033[0;32m'; CYN=$'\033[0;36m'
|
|
BLD=$'\033[1m'; RST=$'\033[0m'
|
|
else
|
|
RED=''; GRN=''; CYN=''; BLD=''; RST=''
|
|
fi
|
|
|
|
info() { echo -e "${CYN}[TEST]${RST} $*"; }
|
|
ok() { echo -e "${GRN}[PASS]${RST} $*"; }
|
|
die() { echo -e "${RED}[FAIL]${RST} $*" >&2; exit 1; }
|
|
|
|
DO_CLEAN=0
|
|
VERBOSE=""
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--clean) DO_CLEAN=1 ;;
|
|
--verbose) VERBOSE="--verbose" ;;
|
|
*) die "Unknown option: $arg" ;;
|
|
esac
|
|
done
|
|
|
|
command -v cmake &>/dev/null || die "cmake not found. Install: pkg install cmake (FreeBSD), apt install cmake (Debian/Ubuntu), dnf install cmake (Fedora)"
|
|
command -v g++ &>/dev/null || command -v clang++ &>/dev/null || die "No C++ compiler found"
|
|
command -v git &>/dev/null || die "git not found (needed to fetch Google Test)"
|
|
|
|
if [[ $DO_CLEAN -eq 1 ]] && [[ -d "$BUILD_DIR" ]]; then
|
|
info "Cleaning build directory..."
|
|
rm -rf "$BUILD_DIR"
|
|
fi
|
|
|
|
if [[ ! -f "$BUILD_DIR/CMakeCache.txt" ]]; then
|
|
info "Configuring test build. First run will fetch Google Test..."
|
|
cmake -S "$SCRIPT_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Debug
|
|
fi
|
|
|
|
info "Building tests..."
|
|
cmake --build "$BUILD_DIR" --parallel "$(cpu_count)"
|
|
|
|
echo ""
|
|
info "${BLD}Running tests...${RST}"
|
|
echo ""
|
|
|
|
CTEST_ARGS=("--test-dir" "$BUILD_DIR" "--output-on-failure")
|
|
[[ -n "$VERBOSE" ]] && CTEST_ARGS+=("--verbose")
|
|
|
|
if ctest "${CTEST_ARGS[@]}"; then
|
|
echo ""
|
|
ok "${BLD}All tests passed.${RST}"
|
|
else
|
|
echo ""
|
|
die "Some tests failed."
|
|
fi |