文件
phonerail/firmware/host/qtest.sh
T
zhou yang和Claude Opus 5.5 b8ad69681f 固件:R2 迁移 R-0 ~ R-6(底板 + 5 片同构刀片)
2026-09-16 完成、当时未提交,这里补提交(原样,不含 09-27 上板的修改)。

- 器件层 / 拓扑层整体从 R1 换到 R2:TCA9548A 分通道、五路同址 INA226 0x40 + 输入侧 0x43、
  刀片 PCA9555(VBUS_EN 挪到 P0.4)、CH224A 只读驱动、风扇闭环 t_thermal
- 新增 i2cbus(mux 原子事务)、slot(刀片 I/O 门面)、host/qtest.sh
- 74HC595 链退役(代码与测试保留)
- 判据阈值与时间常量未动;19 个 ctest 全绿,idf.py build 通过

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-27 10:26:24 +08:00

51 行
1.8 KiB
Bash

#!/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"
[ -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