- Brace every $NAME that is directly followed by a non-ASCII character in the shell scripts: bash 3.2 in a UTF-8 locale read the first byte of the following character as part of the variable name and aborted under set -u (#4, #6). - setup.sh and d2rm_pack.py: the shader translation step is complete only when every entry in the completion marker is ok and every library file exists; the script's exit status is no longer hidden by a pipe (#5). - devbattery.sh / devlock.sh: a missing local timeout or ideviceinfo is reported as such and stops at once, instead of being reported as an offline device and polled for up to an hour (#7). - smoke_mac.sh builds its package for iPhone only regardless of the project default. Reported by @SakuraToErii. The setup.sh part of #4 was also submitted by @hubeiqiao in #6. Co-authored-by: hubeiqiao <12777592+hubeiqiao@users.noreply.github.com>
238 lines
25 KiB
Bash
Executable File
238 lines
25 KiB
Bash
Executable File
#!/bin/bash
|
||
# Switch 路线验收入口:⓪ 启动块清单 ① 改写等价回归 ② 存档逐字节对拍 ③ 对真值的画面闸门 ④ 单测 ⑤ 补拍积压确定性 ⑥ 全档存档事务 ⑧ iOS 构建 ⑨ 功能用例 touchchain ⑩ 局内切运行模式(①–⑩ 并行);任一项红即整体红。
|
||
# r 版本切现行之前必须跑;「完成」以它为准。
|
||
# 用法:dm/verify/accept.sh [--fast|--full] [产物目录=out/<当前代号>-keypage];缺省全档(17 页 + 存档事务 4 例),快档只抽已批准 5 页,⓪①②④⑤不变。
|
||
# 输出:每项一行读数 + 末尾「期望 → 真结果」对位表 + 总用时;日志在 $DM_ROOT/run/verify/dm/accept/<时刻>/;退出码 0 = 全绿
|
||
# 按改动范围选项(先少干活)。改动 = 本树相对 main 分叉点的已提交改动 + 未提交改动的路径并集。映射表:
|
||
# 全部路径 ⊂ { dm/ios/**、docs/**、*.md } → 只跑 ⓪ ⑧(iOS 壳与文档进不了宿主:不跑回归 / 对拍 / 闸门 / 单测 / 功能用例 / 切模式)
|
||
# 全部路径 ⊂ { dm/gfx/**、dm/ios/**、docs/**、*.md } → 跑 ⓪ ③ ④ ⑧ ⑩(图形改动不动改写产物与存档逻辑:不跑 ① ② ②B/C ⑤ ⑥ ⑨)
|
||
# 其余(dm/host、dm/verify、dm/tools、dm/data、重命名、拿不准的任何路径)、没有改动(= 主干头复核)、ACCEPT_ALL=1 → 全量
|
||
# 被跳过的项在输出与对位表里逐项列「⏭ 跳过」,不静默。
|
||
# Acceptance entry for the Switch route: (0) boot block list (1) rewrite equivalence regression (2) byte-for-byte save comparison (3) screenshot gate against ground truth (4) unit tests (5) catch-up tick backlog determinism (6) full-mode save transactions (8) iOS build (9) functional cases touchchain (10) switching operation mode in game ((1)-(10) in parallel); any failing item fails the whole run.
|
||
# Must be run before an r version is made current; "done" is defined by it.
|
||
# Usage: dm/verify/accept.sh [--fast|--full] [build output directory=out/<current codename>-keypage]; default is full mode (17 pages + 4 save transaction cases), fast mode samples only the 5 approved pages, (0)(1)(2)(4)(5) unchanged.
|
||
# Output: one readout line per item + an "expected -> actual result" side-by-side table at the end + total time; logs in $DM_ROOT/run/verify/dm/accept/<timestamp>/; exit code 0 = all green
|
||
# Items are selected by change scope (do less work first). Change = the union of paths of this tree's committed changes relative to the fork point from main + uncommitted changes. Mapping table:
|
||
# all paths ⊂ { dm/ios/**, docs/**, *.md } -> run only (0) (8) (the iOS shell and docs cannot get into the host: no regression / comparison / gate check / unit tests / functional cases / mode switch)
|
||
# all paths ⊂ { dm/gfx/**, dm/ios/**, docs/**, *.md } -> run (0) (3) (4) (8) (10) (graphics changes do not touch the rewrite build output or save logic: no (1) (2) (2)B/C (5) (6) (9))
|
||
# everything else (dm/host, dm/verify, dm/tools, dm/data, renames, any path in doubt), no change (= recheck of the main head), ACCEPT_ALL=1 -> full set
|
||
# Skipped items are listed one by one as 「⏭ 跳过」(skipped) in the output and the side-by-side table, not silently.
|
||
set -u
|
||
export LC_ALL=C
|
||
HERE=$(cd "$(dirname "$0")" && pwd)
|
||
MODE=full
|
||
case "${1:-}" in --fast) MODE=fast; shift;; --full) shift;; --*) echo "ACCEPT RED 未知档位 $1"; exit 2;; esac
|
||
OUT=${1:-$(bash "$(dirname "$0")/../tools/product.sh" path keypage)}
|
||
TR=${TRUTH_RUN:-${DM_ROOT:-$HOME/dm-work}/data/switch/truth_runs/cvd5}
|
||
# 验收入口不得过期(在 dm-gfx 树跑的 accept 落后 main 26 个验证提交——旧仓库页按时长推杆、产物 r12,偶发红无意义):
|
||
# 本树缺 main 上任何改动 dm/verify 的提交即拒跑;超前(正在改验收脚本的分支)不拦
|
||
# The acceptance entry must not be stale (an accept run in the dm-gfx tree was 26 verification commits behind main -- the old stash page pushed the stick by duration, build output r12, and the sporadic failures were meaningless):
|
||
# if this tree lacks any commit on main that changes dm/verify, refuse to run; being ahead (a branch that is changing the acceptance scripts) is not blocked
|
||
STALE=$(git -C "$HERE" log --no-merges --oneline HEAD..main -- "$HERE" 2>/dev/null | wc -l | tr -d ' ')
|
||
[ "${STALE:-0}" = 0 ] || { echo "🔴 ACCEPT 拒跑:本树 dm/verify 落后 main $STALE 个验证提交(验收入口过期,读数无意义)——先合入 main 再跑"; git -C "$HERE" log --no-merges --oneline HEAD..main -- "$HERE" | head -5; exit 1; }
|
||
# 全局锁(同一时刻只跑一路 accept——多棵工作树共用本脚本,负载叠加会拖慢并诱发时序红;串行只降噪,负载下的时序红本身仍是缺陷要修)
|
||
# 去锁进行中:共享路径已按「时刻_树名_进程号」隔离;墙钟 / 负载类判据改完后再换成按工作树的锁
|
||
# Global lock (only one accept runs at any moment -- several worktrees share this script, and stacked load slows things down and induces timing failures; serializing only reduces noise, and a timing failure under load is itself still a defect to fix)
|
||
# Lock removal in progress: shared paths are already isolated by "timestamp_treename_pid"; once the wall clock / load criteria are changed it will be replaced by a per-worktree lock
|
||
TREE=$(basename "$(git -C "$HERE" rev-parse --show-toplevel 2>/dev/null || printf '%s' "$HERE")")
|
||
LOCK=${DM_ROOT:-$HOME/dm-work}/run/verify/dm/accept.lock; ME="${ACCEPT_OWNER:-$TREE} $(git -C "$HERE" rev-parse --abbrev-ref HEAD 2>/dev/null)"
|
||
while ! mkdir "$LOCK" 2>/dev/null; do
|
||
op=$(cat "$LOCK/pid" 2>/dev/null)
|
||
if [ -n "$op" ] && ! kill -0 "$op" 2>/dev/null; then echo "接管陈旧锁(pid $op 已不在:$(cat "$LOCK/owner" 2>/dev/null))"; rm -rf "$LOCK"; continue; fi
|
||
[ "${_waited:-}" ] || { echo "等待 $(cat "$LOCK/owner" 2>/dev/null)(pid ${op:-?})的 accept"; _waited=1; }
|
||
sleep 2
|
||
done
|
||
echo $$ > "$LOCK/pid"; echo "$ME" > "$LOCK/owner"; trap 'rm -rf "$LOCK"' EXIT
|
||
mkdir -p "${DM_ROOT:-$HOME/dm-work}/run/verify/dm/accept"
|
||
L=$(mktemp -d "${DM_ROOT:-$HOME/dm-work}/run/verify/dm/accept/$(date +%m%d_%H%M%S)_${TREE}_$$.XXXXXX") || { echo "ACCEPT RED 无法创建结果目录"; exit 1; }
|
||
T0=$SECONDS
|
||
SKIP=""; SCOPE="全量"
|
||
if [ "${ACCEPT_ALL:-0}" != 1 ]; then
|
||
ROOT=$(git -C "$HERE" rev-parse --show-toplevel 2>/dev/null); MB=$(git -C "$HERE" merge-base HEAD main 2>/dev/null)
|
||
CH=""; [ -n "$ROOT" ] && [ -n "$MB" ] && CH=$( { git -C "$ROOT" diff --name-only --no-renames "$MB" HEAD; git -C "$ROOT" status --porcelain --no-renames | cut -c4-; } 2>/dev/null | sort -u | grep -v '^$') # --no-renames:改名按「删旧 + 加新」两条路径列,旧路径在别的目录时不会被漏掉 | --no-renames: a rename is listed as two paths, "delete old + add new", so the old path is not missed when it is in another directory
|
||
[ -n "${ACCEPT_SCOPE_CH:-}" ] && CH=$(printf '%s\n' "$ACCEPT_SCOPE_CH" | tr ' ' '\n') # 干跑范围判定用:直接给改动路径清单(空格或换行分隔),配 ACCEPT_SCOPE_ONLY=1 只打印 SCOPE 行就退出 | for dry-run scope decisions: give the list of changed paths directly (space or newline separated), and with ACCEPT_SCOPE_ONLY=1 only print the SCOPE line and exit
|
||
# dm/ios 下被编进 Mac 宿主(含宿主单测、触屏功能用例)的源文件,改了等于改宿主:清单从两份 Makefile 里现取,不手写
|
||
# (dm_touch_controls.c 的改动被判成「只在 dm/ios」跳过了 ⑨,把主干的 skill_main 用例弄红)
|
||
# Source files under dm/ios that are compiled into the Mac host (including host unit tests and touch-screen functional cases): changing them equals changing the host; the list is taken live from the two Makefiles, not written by hand
|
||
# (a change to dm_touch_controls.c was judged "only in dm/ios" and skipped (9), turning the skill_main case on main red)
|
||
HOSTDEP=$(grep -hoE 'ios/Sources/[A-Za-z0-9_]+\.(\[ch\]|[chm])' "$HERE/../host/Makefile" "$HERE/../host/tests/Makefile" 2>/dev/null | sed -E 's/^(.*)\.\[ch\]$/\1.c\n\1.h/' | sed 's#^#dm/#' | sort -u)
|
||
CH=$(printf '%s\n' "$CH" | while IFS= read -r f; do [ -n "$f" ] || continue; if printf '%s\n' "$HOSTDEP" | grep -qxF "$f"; then echo "dm/host/(宿主也编) $f"; else echo "$f"; fi; done)
|
||
if [ -n "$CH" ]; then
|
||
if ! printf '%s\n' "$CH" | grep -qvE '^(dm/ios/|docs/)|\.md$'; then SKIP="1 2 3 4 5 6 7 9 10"; SCOPE="改动只在 dm/ios 与文档"
|
||
elif ! printf '%s\n' "$CH" | grep -qvE '^(dm/gfx/|dm/ios/|docs/)|\.md$'; then SKIP="1 2 5 6 7 9"; SCOPE="改动只在 dm/gfx(及 dm/ios、文档)"; fi
|
||
fi
|
||
fi
|
||
echo "SCOPE ${SCOPE}$([ -n "$SKIP" ] && echo ";跳过项序号 ${SKIP}(ACCEPT_ALL=1 强制全量)")"
|
||
[ "${ACCEPT_SCOPE_ONLY:-0}" = 1 ] && exit 0
|
||
# 并行子项都调用增量make;先在锁内只构建一次,避免冷树多个链接器争写同一个dmhost/dSYM。
|
||
# The parallel sub-items all invoke an incremental make; build once first inside the lock, so that on a cold tree several linkers do not compete to write the same dmhost/dSYM.
|
||
if make -s -C "$HERE/../host" > "$L/build.log" 2>&1; then
|
||
echo "BUILD OK 宿主预构建完成,后续子项只做增量核对"
|
||
else
|
||
echo "宿主预构建失败;运行子项未启动,现场保留" > "$L/KEEP"
|
||
cat "$L/build.log"
|
||
echo "ACCEPT RED 宿主预构建失败 日志 $L"
|
||
exit 1
|
||
fi
|
||
item() { # item <序号> <名> <期望> <日志> <读数行正则> <读数行数> <命令…>:结果写 $L/<序号>.row(首行 rc,次行表格行) | item <number> <name> <expected> <log> <readout line regex> <readout line count> <command...>: the result is written to $L/<number>.row (first line rc, second line the table row)
|
||
local k=$1 name=$2 want=$3 log=$4 kl=$5 kn=$6; shift 6; local s=$SECONDS
|
||
case " $SKIP " in *" $k "*) printf '0\n| %s | %s | ⏭ 跳过:%s | 0 秒 |\n' "$name" "$want" "$SCOPE" > "$L/$k.row"; echo "⏭ ${name}(跳过:${SCOPE})"; return 0;; esac
|
||
"$@" > "$L/$log" 2>&1; local rc=$?
|
||
local got=$(grep -E "$kl" "$L/$log" | tail -$kn | tr '\n' ' ') mark
|
||
[ $rc = 0 ] && mark="✅" || mark="🔴"
|
||
printf '%s\n| %s | %s | %s %s | %s 秒 |\n' "$rc" "$name" "$want" "$mark" "${got:-(无读数行,见 ${log})}" "$((SECONDS - s))" > "$L/$k.row"
|
||
echo "$mark ${name}($((SECONDS - s)) 秒)"
|
||
}
|
||
item 0 "⓪ 启动块清单 bootlist.tsv" "存在、构建号与 main.cuts.tsv 一致、与仓库 dm/data/bootlist_<构建号>.tsv 逐字节相同、sha 自洽、块数 > 0、逐块与资源包一致" bootlist.log '^BOOTLIST' 1 "$HERE/bootchk.sh" "$OUT"
|
||
# ①②③ 互相独立,并行(accept ≤ 2 分钟):regress 吃 CPU、host_savecmp 一局宿主、shotgate 4 路宿主
|
||
# (1)(2)(3) are independent of each other and run in parallel (accept <= 2 minutes): regress eats CPU, host_savecmp is one host run, shotgate is 4 hosts in parallel
|
||
regress_both() { # ① 被测产物全套 + 出包产物(iOS 发给玩家的 touch)结构核对(触屏私有门 4 条登记缺口,accept 只核 keypage 一直没暴露) | (1) structure check of the full set of build output under test + the packaging build output (the touch one iOS ships to players) (4 registration gaps in the touch-screen private gates went unexposed because accept only checked keypage)
|
||
local rc=0 touch_out=${DM_TOUCH_OUT:-$(bash "$(dirname "$0")/../tools/product.sh" path touch)}
|
||
"$HERE/regress.sh" "$OUT" || rc=1
|
||
"$HERE/regress.sh" --struct-only "$touch_out" || rc=1
|
||
return $rc
|
||
}
|
||
item 1 "① 改写等价回归 regress(+ 出包产物 touch 结构核对)" "被测产物三模块 STRUCT/EQUIV OK、GATEFN 全过;touch 三模块 STRUCT OK、GATEFN 全过;两行 REGRESS OK" regress.log '^(STRUCT|EQUIV|REGRESS|GATEFN)' 13 regress_both &
|
||
savecmp_gate() { # host_savecmp + 宿主日志红线(只比存档字节、没看日志,缺着色器 20 行【红】连报 5 次绿);$1 = 本项日志名 | host_savecmp + host log a failure line line (it only compared save bytes and did not look at the log, so a missing shader with 20 lines of 【红】(red) was reported green 5 times in a row); $1 = this item's log name
|
||
bash "$HERE/../tools/host_savecmp.sh" "$TR" "$OUT"; local rc=$?
|
||
local hd=$(sed -n 's/^局目录 //p' "$L/${1:-savecmp.log}" | head -1) r
|
||
r=$("$HERE/logred.sh" "$hd/host.log"); local lrc=$?
|
||
echo "HOSTLOG 宿主日志红线 $(echo "$r" | cut -f1) 行 $(echo "$r" | cut -f2)($hd/host.log)"
|
||
[ $lrc = 0 ] || { [ $lrc = 2 ] && echo "HOSTLOG 找不到宿主日志,判红"; rc=1; }
|
||
# 预取命中只报不判:预取是性能优化,命中数取决于最低 QoS 预取线程跑了多久,负载下实测 5270→3244、2148,
|
||
# 截止点无论取「到选角」还是整局都和墙钟赛跑;清单对不对是静态性质,归 ⓪ bootchk(逐块核资源包)
|
||
# Prefetch hits are only reported, not judged: prefetch is a performance optimization, and the hit count depends on how long the lowest-QoS prefetch thread got to run, measured under load 5270->3244, 2148,
|
||
# so whether the cutoff is taken "at character select" or over the whole run it is a race against the wall clock; whether the list is correct is a static property and belongs to (0) bootchk (checks the resource package block by block)
|
||
local hit=$(grep -o 'DM_TACT_PREFETCH:命中 [0-9]*' "$hd/host.log" | tail -1 | grep -o '[0-9]*$')
|
||
echo "PREFETCH 预取命中 ${hit:-无读数} 块(只报不判)"
|
||
return $rc
|
||
}
|
||
item 2 "② 存档逐字节对拍 host_savecmp $(basename "$TR")" "逐拍 6 格一致、正对照一致、负对照不一致、宿主日志无红线" savecmp.log 'SELFCMP|^SAVECMP|结论|^HOSTLOG|^PREFETCH' 6 savecmp_gate savecmp.log &
|
||
gatebc() {
|
||
local rc=0 rule_out=${DM_RULE_OUT:-$(bash "$(dirname "$0")/../tools/product.sh" path rules)} self_out=${DM_LOGICSELF_OUT:-$(bash "$(dirname "$0")/../tools/product.sh" path touch)}
|
||
if [ ! -f "$HERE/rulegate.sh" ] || [ ! -f "$HERE/logicself.sh" ]; then
|
||
echo "RULEGATE TEST FIXTURE 未装载脚本"
|
||
echo "LOGICSELF TEST FIXTURE 未装载脚本"
|
||
return 0
|
||
fi
|
||
bash "$HERE/rulegate.sh" 400 "$rule_out" || rc=1
|
||
bash "$HERE/logicself.sh" "$self_out" 230 || rc=1
|
||
return $rc
|
||
}
|
||
item 7 "②B/C 逻辑闸门 rulegate + logicself" "RULEGATE 400 逐拍六组一致;LOGICSELF 230 逐拍自身基线一致" logic_gate.log '^(RULEGATE|LOGICSELF)' 8 gatebc &
|
||
# ⑤ 确定性回归:拍 400 入口人为睡 300 ms 造补拍积压,冻结拍仍须落在 401、存档正绿负红
|
||
# (5) Determinism regression: sleep 300 ms artificially at the entry of tick 400 to build a catch-up tick backlog; the frozen tick must still land on 401, and the save must pass in the positive case and fail in the negative case
|
||
lag_gate() { # ⑤:savecmp_gate + 射程(证明不是空跑——宿主日志「下一拍时限 A → B」的增量须 ≥ 200;注入时实测 281、不注入 28) | (5): savecmp_gate + coverage (proves it is not an empty run -- the increment of the host log 「下一拍时限 A → B」(next tick deadline A -> B) must be >= 200; measured 281 with injection, 28 without)
|
||
savecmp_gate savecmp_lag.log; local rc=$?
|
||
local hd=$(sed -n 's/^局目录 //p' "$L/savecmp_lag.log" | head -1)
|
||
local inc=$(grep -o '下一拍时限 [0-9]* → [0-9]*' "$hd/host.log" | tail -1 | awk '{print $4 - $2}')
|
||
if [ -n "$inc" ] && [ "$inc" -ge 200 ]; then echo "LAGRANGE 积压已造出:下一拍时限增量 ${inc}(≥ 200)"; else echo "LAGRANGE 空跑:下一拍时限增量 ${inc:-无读数}(须 ≥ 200)"; rc=1; fi
|
||
return $rc
|
||
}
|
||
item 5 "⑤ 补拍积压下冻结拍确定性 DM_TEST_LAG=400 $(basename "$TR")" "冻结拍 401(目标 401)不带【红】、正对照一致、负对照不一致、宿主日志无红线、积压射程增量 ≥ 200" savecmp_lag.log 'SELFCMP|^SAVECMP|结论|^HOSTLOG|^LAGRANGE|^PREFETCH' 7 env DM_TEST_LAG=400 bash -c "$(declare -f savecmp_gate lag_gate); HERE=$HERE TR=$TR OUT=$OUT L=$L lag_gate" &
|
||
func_cases() {
|
||
local case_dir name total green=0 status elapsed note log detail reported
|
||
local cases=() pending=()
|
||
while IFS= read -r -d '' case_dir; do
|
||
[ -f "$case_dir/script.txt" ] && [ -f "$case_dir/assert.py" ] || continue
|
||
# 用例目录里有 pending 文件 = 待接入(如等宿主改动才能进时限):不跑,但必须列出,不静默跳过;首行写原因
|
||
# A pending file in a case directory = waiting to be wired in (e.g. waiting for a host change before it can fit the time limit): not run, but must be listed, not silently skipped; the first line gives the reason
|
||
if [ -f "$case_dir/pending" ]; then pending+=("$(basename "$case_dir"):$(head -1 "$case_dir/pending")"); continue; fi
|
||
cases+=("$(basename "$case_dir")")
|
||
done < <(find "$HERE/touchcases" -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)
|
||
total=${#cases[@]}
|
||
if [ "$total" -eq 0 ]; then
|
||
echo 'FUNC 0/0'
|
||
return 1
|
||
fi
|
||
# 令牌池限并发(FUNC_JOBS,缺省 2;写法同 shotgate):8 例同时起时每例的启动加载被拖长 4–5 倍(mini 实测单跑 2.8 s 撤读取画面、
|
||
# 8 路并行 11–14 s),时限 20 s 卡的是并行启动而不是用例本身;快进后每例单跑 4–5 s,2 个一批、本项总墙钟约 30 s;mini(12 核)上背景 6 宿主 + 3 个一批仍有 15–22 s,故取 2
|
||
# 功能用例跑在 iOS 包同一份界面覆盖层上:起跑前生成一次(幂等,约 3 秒),各例共用;不依赖 ⑧ iOS 构建的先后
|
||
# A token pool limits concurrency (FUNC_JOBS, default 2; written the same way as shotgate): with 8 cases started at once, each case's startup loading is stretched 4–5 times (measured on the second Mac: 2.8 s to take down the loading screen when run alone,
|
||
# 11–14 s with 8 in parallel), so the 20 s limit was catching the parallel startup rather than the case itself; after fast-forward each case takes 4–5 s alone, and with batches of 2 the total wall clock of this item is about 30 s; on the second Mac (12 cores) with 6 background hosts + batches of 3 it is still 15–22 s, hence 2
|
||
# Functional cases run on the same UI overlay as the iOS app: generated once before starting (idempotent, about 3 seconds) and shared by all cases; does not depend on the ordering of (8) iOS build
|
||
python3 "$HERE/../ios/tools/gen_romfs_overlay.py" "${DM_ROMFS_SRC:-${DM_ROOT:-$HOME/dm-work}/data/switch/3.3.94012/Update/RomFS}" "$L/romfs_overlay" > /dev/null 2>"$L/func_overlay.err" || { echo "FUNCFAIL 界面覆盖层生成失败:$(tail -1 "$L/func_overlay.err")"; echo 'FUNC 0/0'; return 1; }
|
||
export DM_ROMFS_OVERLAY="$L/romfs_overlay"
|
||
local sem="$L/func.sem.$$"; mkfifo "$sem" || return 1; exec 8<>"$sem"; rm -f "$sem"
|
||
for _ in $(seq 1 "${FUNC_JOBS:-2}"); do echo >&8; done
|
||
for name in "${cases[@]}"; do
|
||
read -r -u 8
|
||
(
|
||
log="$L/func_${name}.log"
|
||
local started=$SECONDS rc=0
|
||
timeout 120s env DM_TOUCH_RUNROOT="$L/touchchain/$name" bash "$HERE/touchchain.sh" "$name" > "$log" 2>&1 || rc=$?
|
||
reported=$(awk '/^TOUCHCHAIN / {print $(NF - 1)}' "$log" | tail -1)
|
||
elapsed=${reported:-$((SECONDS - started))}
|
||
status=RED
|
||
[ "$rc" -eq 0 ] && [ "$elapsed" -le "${FUNC_LIMIT_S:-60}" ] && status=OK # 判对错只看断言;墙钟只作卡死兜底(60 s)。20 s 硬线在多线并行 accept 时反复误红,用例单跑 4–5 s | right or wrong is judged by assertions only; wall clock is only a backstop for hangs (60 s). The hard 20 s line repeatedly failed spuriously when several accept runs ran in parallel; a case run alone takes 4–5 s
|
||
printf '%s %s\n' "$status" "$elapsed" > "$L/func_${name}.row"
|
||
echo >&8
|
||
) &
|
||
done
|
||
wait; exec 8>&-
|
||
for name in "${cases[@]}"; do
|
||
read -r status elapsed < "$L/func_${name}.row"
|
||
note=''
|
||
[ "$elapsed" -gt 20 ] && note='(慢:> 20 s,本机负载高?)'; [ "$elapsed" -gt "${FUNC_LIMIT_S:-60}" ] && note="(超卡死兜底 ${FUNC_LIMIT_S:-60} s)"
|
||
printf 'FUNCCASE %s %s %s 秒%s\n' "$name" "$status" "$elapsed" "$note"
|
||
if [ "$status" = OK ]; then
|
||
green=$((green + 1))
|
||
else
|
||
log="$L/func_${name}.log"
|
||
detail=$(grep -E '局目录:|断言失败:' "$log" | tail -2 | tr '\n' ' ')
|
||
[ -n "$detail" ] || detail="日志:$log"
|
||
printf 'FUNCFAIL %s %s\n' "$name" "$detail"
|
||
fi
|
||
done
|
||
printf 'FUNC %s/%s\n' "$green" "$total"
|
||
[ ${#pending[@]} -eq 0 ] || { printf 'FUNCPENDING 待接入 %s 例:' "${#pending[@]}"; printf '%s;' "${pending[@]}"; echo; }
|
||
[ "$green" -eq "$total" ]
|
||
}
|
||
item 9 "⑨ 功能用例 touchchain" "自动收集 script.txt + assert.py 用例;各例并行;断言通过(墙钟 60 s 只作卡死兜底)" func.log '^(FUNCCASE|FUNC|FUNCFAIL|FUNCPENDING)' 1000 func_cases &
|
||
PAGES=()
|
||
[ "$MODE" = fast ] && PAGES=(camp_e stash wild charselect skilltree)
|
||
PAGE_NAMES=${PAGES[*]:-$(cd "$HERE/shotgate_pages" && ls *.json | sed 's/\.json$//' | tr '\n' ' ')}
|
||
item 3 "③ 画面闸门 shotgate ${MODE}(${PAGE_NAMES})" "每页对真值绿(结构 / 非黑 / 网格 / 命名区域 / 应有元素 / 宿主日志无【红】)" shotgate.log 'SHOTGATE_ALL' 1 "$HERE/shotgate.sh" "$OUT" ${PAGES[@]+"${PAGES[@]}"} &
|
||
unit_tests() { # ④ 宿主与图形单测(E:SHOT 合入后 gfx 单测链接失败,accept 却绿):任何失败或构建 / 链接错误即红 | (4) host and graphics unit tests (after E:SHOT was merged the gfx unit test failed to link, yet accept was green): any failure or build / link error is a failure
|
||
local rc=0
|
||
"${DM_ROOT:-$HOME/dm-work}/build/cache/dm/venv/bin/python" "$HERE/ryu/test_selfcmp.py" > "$L/unit_selfcmp.log" 2>&1 && echo "UNIT selfcmp 通过" || { echo "UNIT selfcmp 失败(见 unit_selfcmp.log)"; rc=1; }
|
||
"${DM_ROOT:-$HOME/dm-work}/build/cache/dm/venv/bin/python" "$HERE/ryu/test_plan.py" > "$L/unit_plan.log" 2>&1 && echo "UNIT plan 通过" || { echo "UNIT plan 失败(见 unit_plan.log)"; rc=1; }
|
||
make -j8 -C "$HERE/../host/tests" run > "$L/unit_host.log" 2>&1 && echo "UNIT host 通过" || { echo "UNIT host 失败:$(grep -m1 -iE 'error|fail|失败|红' "$L/unit_host.log" | cut -c1-140)"; rc=1; }
|
||
make -j8 -C "$HERE/../gfx/tests" run > "$L/unit_gfx.log" 2>&1 && echo "UNIT gfx 通过" || { echo "UNIT gfx 失败:$(grep -m1 -iE 'error|fail|失败|红|undefined' "$L/unit_gfx.log" | cut -c1-140)"; rc=1; }
|
||
# iOS 触摸层单测(这一套从没接进闸门,回城钮改版后红了一天没人看见)
|
||
# iOS touch layer unit tests (this set was never wired into the gate check, and after the town portal button redesign it was red for a day without anyone seeing it)
|
||
make -C "$HERE/../ios/tests" test > "$L/unit_ios.log" 2>&1 && echo "UNIT ios 通过" || { echo "UNIT ios 失败:$(grep -m1 -E 'FAIL|Error|error' "$L/unit_ios.log" | cut -c1-140)"; rc=1; }
|
||
# accept 自己的接线单测(加 ⑧ 时漏过替身,test_accept 4 例红而 accept 全绿);它用替身起 accept,不跑真宿主,几秒
|
||
# accept's own wiring unit test (when (8) was added a stand-in was missed, test_accept had 4 failure cases while accept was all green); it starts accept with stand-ins, does not run the real host, and takes a few seconds
|
||
(cd "$HERE" && python3 -m unittest -q test_accept) > "$L/unit_accept.log" 2>&1 && echo "UNIT accept 通过" || { echo "UNIT accept 失败:$(grep -m1 -E '^(FAIL|ERROR):' "$L/unit_accept.log" | cut -c1-140)"; rc=1; }
|
||
return $rc
|
||
}
|
||
item 4 "④ 单测 selfcmp + plan + make -C dm/host/tests run + dm/gfx/tests run + dm/ios/tests test + test_accept" "六套全过、无构建 / 链接错误" unit.log '^UNIT' 6 unit_tests &
|
||
ios_build_gate() {
|
||
local s=$SECONDS raw="$L/iosbuild-command.log"
|
||
DM_NOINSTALL=1 DM_IOS_DD="$HERE/../../.iosdd" bash "$HERE/../ios/run.sh" build > "$raw" 2>&1
|
||
local rc=$? elapsed=$((SECONDS - s))
|
||
if [ "$rc" = 0 ]; then
|
||
echo "IOSBUILD OK 用时 $elapsed 秒"
|
||
else
|
||
echo "IOSBUILD RED 用时 $elapsed 秒"
|
||
grep -m1 -E 'error:' "$raw" || true
|
||
fi
|
||
return "$rc"
|
||
}
|
||
item 8 "⑧ iOS 构建(只编不装)" "DM_NOINSTALL=1 工作树派生目录构建成功;首个 error 可见" iosbuild.log '^IOSBUILD (OK|RED)' 2 ios_build_gate &
|
||
# ⑩ 局内切运行模式(真机过热切掌机即崩、各闸门都不切模式没抓到):进局后 主机 → 掌机,进程须活着继续出帧
|
||
# (10) Switching operation mode in game (a real device overheating and switching to handheld crashed immediately, and no gate check switched modes so it was not caught): after joining a run, docked -> handheld, and the process must stay alive and keep producing frames
|
||
item 10 "⑩ 局内切运行模式 opmode" "切换前已进局;取走通知 30/31;活到 timeout 无 CRASH;切换后 ≥ 300 帧;宿主日志无红线" opmode.log '^OPMODE (OK|RED)' 1 bash "$HERE/opmode.sh" "$OUT" &
|
||
# 事务四局串行本身占约 90 秒,列入全档;与其余项目独立,原来的六项判据保持不变。
|
||
# The four transaction runs in series take about 90 seconds by themselves and are put in the full mode; they are independent of the other items, and the original six criteria stay unchanged.
|
||
[ "$MODE" = full ] && item 6 "⑥ 存档事务 save_txn_regress" "4/4 注入命中;已提交文件同期望版;校验和自洽;残缺工作目录 / 拒绝日志负对照成立" save_txn.log '^✓|^✗|^结论|^SAVE_TXN' 6 bash "$HERE/../tools/save_txn_regress.sh" "$OUT" &
|
||
wait
|
||
allrc=0; rows=()
|
||
ITEMS=(0 1 2 3 4 5 7 8 9 10); [ "$MODE" = full ] && ITEMS+=(6)
|
||
for k in "${ITEMS[@]}"; do { read -r rc; read -r row; } < "$L/$k.row"; [ "$rc" = 0 ] || allrc=1; rows+=("$row"); done
|
||
[ "$allrc" = 0 ] || echo "ACCEPT $MODE 红;本目录保留,不删不覆盖" > "$L/KEEP"
|
||
echo; echo "| 项 | 期望 | 真结果 | 用时 |"; echo "|---|---|---|---|"; printf '%s\n' "${rows[@]}"
|
||
echo; echo "ACCEPT $([ $allrc = 0 ] && echo OK || echo RED) 档位 $MODE 产物 $(basename "$OUT") 总用时 $((SECONDS - T0)) 秒 日志 $L"
|
||
exit $allrc
|