#!/usr/bin/env bash # 单个测试的「快编快跑」——给并行开工用(R2 迁移期间,别的测试可能还编不过, # host/test.sh 的 cmake GLOB 会被它们卡住)。 # # bash host/qtest.sh test_rail_cfg [test_slot ...] # # 它只编「core 源码 + unity + 你指定的那一个测试」,产物扔进 host/.q/, # 不碰 host/build,所以多个会话同时跑互不干扰。 # # ⚠️ 全绿之后仍然要跑一次完整的 `bash host/test.sh` —— 那一份才是 DoD 认的。 set -u cd "$(dirname "$0")/.." || exit 1 OUT=host/.q mkdir -p "$OUT" INC="-Imain -Icomponents/phonerail_hal/include -Icomponents/phonerail_hal/sim -Icomponents/drv/include -Ithird_party/unity" # app_main.c 是 ESP 专用入口,宿主机不编。 CORE="main/version.c main/rail.c main/rail_cfg.c main/i2cbus.c main/slot.c main/sched.c main/tasks.c main/t_safety.c main/t_actuator.c main/evlog.c main/cmd_json.c main/cmd.c main/cmd_exec.c main/cmd_report.c main/ulink.c main/cmd_net.c main/netcfg.c main/mlink.c" [ -f main/t_thermal.c ] && CORE="$CORE main/t_thermal.c" DRV="components/drv/ina226.c components/drv/dac63204.c components/drv/sr595.c components/drv/pca9555.c components/drv/tca9548a.c components/drv/ch224a.c" HALDIR=components/phonerail_hal SIM="$HALDIR/hal_err.c $HALDIR/hal_i2c_acct.c $HALDIR/sim/hal_lock_sim.c $HALDIR/sim/sim_hal.c $HALDIR/sim/hal_i2c_sim.c $HALDIR/sim/hal_gpio_sim.c $HALDIR/sim/sim_sr595.c $HALDIR/sim/sim_pca9555.c $HALDIR/sim/hal_pwm_sim.c $HALDIR/sim/hal_time_sim.c $HALDIR/sim/hal_store_sim.c" rc=0 for t in "$@"; do src="test/$t.c" if [ ! -f "$src" ]; then echo "!! 没有 $src"; rc=1; continue fi echo "=== $t ===" # shellcheck disable=SC2086 if gcc -std=c11 -Wall -Wextra -Werror -g $INC \ "$src" third_party/unity/unity.c $CORE $DRV $SIM \ -o "$OUT/$t.exe"; then "$OUT/$t.exe" || rc=1 else rc=1 fi done exit $rc