forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB052d1d3Tahinli2 months ago3627 commits

av1-stage-suite.sh124 lines, 5.0 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# av1-stage-suite.sh — stage an ec-av1 suite on a server host, behind the preflight
3# gate. A staging whose pin audit or rung check FAILED, or whose checkers never
4# ran, MUST NOT reach `=== SUITE`.
5#
6# WHY THIS EXISTS (lane-av1stagegaps, 2026-09-30). The hand-written staging
7# driver logged the checker outcome and continued regardless:
8#
9# === ORACLE RUNG CHECKER
10# rungs_exit=1 ok_count=0
11# === SUITE
12#
13# so a green suite on a host meant nothing about its preflight. Three states —
14# passed, failed, never ran — all looked the same. This driver runs
15# scripts/av1-suite-preflight.sh under `set -e` and stops there.
16#
17# Usage:
18# scripts/av1-stage-suite.sh --name <suite> --tree <dir> [--tarball <tgz>]
19# [--skip <cargo-test-arg>]... [-- command...]
20#
21# Defaults: no cargo-test-arg means
22# cargo test -p ec-av1 --lib -- --test-threads=1
23#
24# Env (all passed to the unit):
25# CARGO_TARGET_DIR, TMPDIR defaulted under $HOME/gates/<name>-*
26# EC_AV1_REQUIRE_AOMENC=1, EC_AV1_REQUIRE_FFMPEG=1, EC_REQUIRE_FIXTURES=1
27# SUITE_RUNG_WAIVER=<reason> required to accept rung_check=not-run
28#
29# Exit: 0 the unit was started; non-zero the preflight BLOCKED and no unit
30# exists. `systemctl --user is-active <name>-suite` is the only thing that
31# starts a suite, so a blocked staging leaves the host idle on purpose.
32
33set -uo pipefail
34
35NAME=""
36TREE=""
37TARBALL=""
38declare -a SKIPS=()
39declare -a CMD=()
40DRY_RUN=0
41while [ $# -gt 0 ]; do
42 case "$1" in
43 --name) NAME=$2; shift 2 ;;
44 --tree) TREE=$2; shift 2 ;;
45 --tarball) TARBALL=$2; shift 2 ;;
46 --skip) SKIPS+=(--skip "$2"); shift 2 ;;
47 --dry-run) DRY_RUN=1; shift ;;
48 --) shift; CMD=("$@"); break ;;
49 -h|--help) sed -n '2,28p' "$0"; exit 0 ;;
50 *) echo "unknown argument: $1" >&2; exit 2 ;;
51 esac
52done
53[ -n "$NAME" ] && [ -n "$TREE" ] || { echo "usage: --name <suite> --tree <dir> [--tarball <tgz>] [--skip <arg>]... [-- cmd...]" >&2; exit 2; }
54[ -d "$TREE" ] || { echo "no such tree: $TREE" >&2; exit 2; }
55
56# 1. The staged tree needs a real git checkout with a POPULATED index. A bare
57# `git init` leaves the index empty and pin-gate-audit.py's
58# `git ls-files --error-unmatch` then reports every pin as uncommitted — a
59# staging artefact indistinguishable from the defect invariant 4 exists to
60# catch (wave-3c-b correction). Test rev-parse, not `[ -d .git ]`: a worktree
61# copy and a `git archive` untar both leave a `.git` FILE.
62git -C "$TREE" rev-parse --git-dir >/dev/null 2>&1 || {
63 echo "staging defect: $TREE is not a git checkout; memguard-runner.sh dies with exit 128" >&2
64 exit 2
65}
66if [ -z "$(git -C "$TREE" ls-files | head -1)" ]; then
67 echo "staging defect: $TREE has an empty index; run git add -A after the untar" >&2
68 exit 2
69fi
70
71# 2. Both gitignored lanes dumps: missing them fails exactly 2 tests that are
72# not a decoder regression.
73for f in intrarect_dump.expected.txt wedge_libaom.expected.txt; do
74 [ -f "$TREE/lanes/$f" ] || { echo "staging defect: $TREE/lanes/$f missing" >&2; exit 2; }
75done
76
77TARGET=${CARGO_TARGET_DIR:-$HOME/gates/target-$NAME}
78TMP=${TMPDIR:-$HOME/gates/tmp-$NAME}
79mkdir -p "$TARGET" "$TMP"
80
81echo "=== host=$(hostname) commit=$(git -C "$TREE" rev-parse HEAD) date=$(date -Is)"
82echo "=== cargo=$(command -v cargo || echo MISSING) aomenc=${EC_AV1_AOMENC:-unset} aomdec=${EC_AV1_AOMDEC:-unset} ffmpeg=$(command -v ffmpeg || echo MISSING)"
83if [ -n "$TARBALL" ]; then
84 echo "=== tarball=$(sha256sum "$TARBALL" | cut -c1-16) -> $TREE"
85fi
86
87# 3. THE GATE. `set -e` is the whole mechanism: a non-zero verdict aborts this
88# script before systemd-run is ever reached, so no unit exists and no suite
89# runs. There is no path from a blocked verdict to `=== SUITE`.
90set -e
91echo "=== PIN-GATE PREFLIGHT + ORACLE RUNG CHECKER"
92EC_REQUIRE_FIXTURES=${EC_REQUIRE_FIXTURES:-1} \
93EC_FIXTURE_SHAPE_STRICT=${EC_FIXTURE_SHAPE_STRICT:-1} \
94 bash "$TREE/scripts/av1-suite-preflight.sh" --tree "$TREE"
95set +e
96
97echo "=== SUITE"
98if [ "$DRY_RUN" = 1 ]; then
99 echo "dry-run: would start unit $NAME-suite in $TREE (target $TARGET, tmp $TMP)"
100 exit 0
101fi
102
103if [ ${#CMD[@]} -eq 0 ]; then
104 CMD=(cargo test -p ec-av1 --lib -- --test-threads=1)
105fi
106declare -a quoted=()
107for a in "${SKIPS[@]}"; do quoted+=("$a"); done
108
109LOG=$HOME/gates/$NAME-suite.log
110mkdir -p "$HOME/gates"
111systemd-run --user --unit="$NAME-suite" -p MemoryMax=5G \
112 -p WorkingDirectory="$TREE" \
113 --setenv="CARGO_TARGET_DIR=$TARGET" \
114 --setenv="TMPDIR=$TMP" \
115 --setenv=EC_NOMEMGUARD=1 \
116 --setenv=EC_AV1_REQUIRE_AOMENC=1 \
117 --setenv=EC_AV1_REQUIRE_FFMPEG=1 \
118 --setenv=EC_REQUIRE_FIXTURES=1 \
119 --setenv="EC_FIXTURES=${EC_FIXTURES:-$TREE/fixtures}" \
120 ${EC_AV1_AOMENC:+--setenv=EC_AV1_AOMENC=$EC_AV1_AOMENC} \
121 ${EC_AV1_AOMDEC:+--setenv=EC_AV1_AOMDEC=$EC_AV1_AOMDEC} \
122 --setenv="PATH=$HOME/.cargo/bin:/usr/local/bin:/usr/bin:/bin" \
123 /usr/bin/bash -lc "cd '$TREE' && ${CMD[*]} ${quoted[*]-} > '$LOG' 2>&1"
124echo "started $NAME-suite; real test output: $LOG"