interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / tests / fw_diff.sh

292 lines · 16677 bytes Raw Blame History
1#!/bin/sh
2# fw_diff.sh: builds fwprep (gsp/sha2.om gsp/inflate.om gsp/fw.om gsp/bindata.om fwprep.om) with the
3# pinned omc and the two C referees from aienux PR #441 (kernel/tools/ck_gsp_fw_inspect.c and
4# kernel/tools/ck_gsp_bindata_extract.c with argus/sha256.c, compiled fresh into a temp dir as
5# test-only referees, never linked into the product), then requires:
6# - fwprep stdout = C inspect stdout + C FMC extract stdout + C boot extract stdout + the fwprep
7# lines expected from the C --out files, byte for byte, exit 0;
8# - every output cmp-identical to the C --out file it comes from, fw.manifest identical to one
9# rebuilt here from the C outputs (od/wc/sha256sum), and the pinned digests and descriptor;
10# - negative controls refused by the C and by fwprep (exit 2, C stdout prefix identical, no
11# fw.manifest left, a stale one removed): truncated firmware, .fwsignature_gb10y renamed,
12# a flipped compressed byte (CRC-32), a flipped deflate body byte, a flipped UCODE_HASH byte;
13# plus fwprep's own refusals: wrong function, missing FWFILE (C stderr wording, exit 1),
14# OUTDIR not a directory (exit 3), usage (exit 1).
15# Host only: reads the firmware and bindata files, writes a temp dir; no device.
16# Env: AIENUX, OMC, FW (gsp_ga10x.bin), OGKM (open-gpu-kernel-modules-580.173.02 tree),
17# SHA2_OM INFL_OM FW_OM BD_OM FWPREP_OM (units to test; mutants use these).
18# Exit 0 PASS, 1 differ, 2 setup, 3 omc failure.
19set -u
20here=$(cd "$(dirname "$0")/.." && pwd)
21AIENUX=${AIENUX:-/home/drakestapleton/work/OwnDriver/aienux}
22OMC=${OMC:-$here/build/omc}
23FW=${FW:-/lib/firmware/nvidia/580.173.02/gsp_ga10x.bin}
24OGKM=${OGKM:-/home/drakestapleton/workspace/_ext/open-gpu-kernel-modules-580.173.02}
25SHA2_OM=${SHA2_OM:-$here/gsp/sha2.om}
26INFL_OM=${INFL_OM:-$here/gsp/inflate.om}
27FW_OM=${FW_OM:-$here/gsp/fw.om}
28BD_OM=${BD_OM:-$here/gsp/bindata.om}
29FWPREP_OM=${FWPREP_OM:-$here/fwprep.om}
30OMC_SHA=$(sed -n 's/^OMC_SHA256=//p' "$here/tools/omc.pin")
31run() { nice -n 19 taskset -c "${AIEN_TEST_CPUS:-0-9,15-19}" "$@"; }
32fail() { echo "fw_diff: FAIL $2"; exit "$1"; }
33
34FW_SHA=32cb7cf3e77f97e92f6e92135939ccb3ba382748144569c0dfccf3338d43d963
35case "${1:-gb10b}" in
36gb10b)
37 family=gb10y
38 chip=GB10B
39 manifest=fw.manifest
40 FMC_C_SHA=2861be1864befa21e4fe4a5d088dae816de8cd8f03359de9f7d35cff910c8957
41 BOOT_C_SHA=c9c0c0073837b8e38ef6fc94c3c531d6f03b22003fe084b0f9066631f4a0397b
42 FMC_IMG_SHA=b13ead4b9a6b8a0d268f3094cc4f4521d6be8a9a525edbc9a8f3f397c86f1f2e
43 BL_IMG_SHA=427a691d8453f02548d395f40ac900eb0d5b8ea864e8f14f958eef890ba400a2
44 fmc_size=195912; boot_size=196608; mdata_size=42496; mcode_off=45056
45 ;;
46gb20b)
47 family=gb20y
48 chip=GB20B
49 manifest=fw.gb20b.manifest
50 FMC_C_SHA=035179cfd878d6bed7308842b0d95612fbb0390149ebee7532b23f375727d8b6
51 BOOT_C_SHA=71e3c512eaa78c60518f6c907826df36bed8e9cbbe8ea8257ca0b1c45d131dec
52 FMC_IMG_SHA=b92f83c1250019af11162d9ee471b8fb74081ea598cf6added0bee7a3663e2be
53 BL_IMG_SHA=6da8510c912ccd5a8b73f9a5cce9e0f4ea657aa430431d2f8e4874834aeadb94
54 fmc_size=212296; boot_size=212992; mdata_size=58880; mcode_off=61440
55 ;;
56*) fail 2 "unknown test profile" ;;
57esac
58FMC_F=kgspGetBinArchiveGspRmFmcGfwProdSigned_$chip
59BOOT_F=kgspGetBinArchiveGspRmBoot_$chip
60FMC_C=g_bindata_$FMC_F.c
61BOOT_C=g_bindata_$BOOT_F.c
62DESC_PIN="version=5 bootloader_off=0 bootloader_size=0 bl_param_off=0 bl_param_size=0 elf_off=0 elf_size=0 app_version=0 manifest_off=0 manifest_size=2560 mdata_off=2560 mdata_size=$mdata_size mcode_off=$mcode_off mcode_size=150784 monitor_enabled=1"
63G=$OGKM/src/nvidia/generated
64
65got=$(sha256sum "$OMC" | cut -d' ' -f1)
66[ "$got" = "$OMC_SHA" ] || fail 2 "omc sha256 $got, pinned $OMC_SHA"
67[ "$(sha256sum < "$FW" | cut -d' ' -f1)" = "$FW_SHA" ] || fail 2 "firmware sha256 differs from the 580.173.02 pin: $FW"
68[ "$(sha256sum < "$G/$FMC_C" | cut -d' ' -f1)" = "$FMC_C_SHA" ] || fail 2 "FMC bindata sha256 differs from the pin"
69[ "$(sha256sum < "$G/$BOOT_C" | cut -d' ' -f1)" = "$BOOT_C_SHA" ] || fail 2 "boot bindata sha256 differs from the pin"
70if grep -n 'vfio\|mapnew\|mapget\|mapset\|/dev/\|/sys/' "$SHA2_OM" "$INFL_OM" "$FW_OM" "$BD_OM" "$FWPREP_OM"; then
71 fail 2 "a firmware unit names a device"
72fi
73
74t=$(mktemp -d /tmp/fw_diff.XXXXXX) || exit 2
75trap 'rm -rf "$t"' EXIT
76k=$AIENUX/native
77for tool in ck_gsp_fw_inspect ck_gsp_bindata_extract; do
78 run cc -std=c11 -O1 -Wall -Werror -I"$k/argus" -o "$t/$tool" "$k/kernel/tools/$tool.c" "$k/argus/sha256.c" \
79 || fail 2 "C referee build $tool"
80done
81cat "$SHA2_OM" "$INFL_OM" "$FW_OM" "$BD_OM" "$FWPREP_OM" | run "$OMC" > "$t/fwprep" || fail 3 "omc build"
82chmod +x "$t/fwprep"
83
84# ---- positive run on the real inputs ----
85run "$t/ck_gsp_fw_inspect" inspect "$FW" --family "$family" > "$t/insp.txt" || fail 2 "C inspect refused the real firmware"
86run "$t/ck_gsp_bindata_extract" extract "$G/$FMC_C" > "$t/fmc.txt" || fail 2 "C extract refused FMC"
87run "$t/ck_gsp_bindata_extract" extract "$G/$BOOT_C" > "$t/boot.txt" || fail 2 "C extract refused boot"
88mkdir "$t/cfmc" "$t/cboot"
89run "$t/ck_gsp_bindata_extract" extract "$G/$FMC_C" --out "$t/cfmc" > /dev/null || fail 2 "C extract --out FMC"
90run "$t/ck_gsp_bindata_extract" extract "$G/$BOOT_C" --out "$t/cboot" > /dev/null || fail 2 "C extract --out boot"
91cf=$t/cfmc/$FMC_F
92cb=$t/cboot/$BOOT_F
93cat "$t/insp.txt" "$t/fmc.txt" "$t/boot.txt" > "$t/want.txt"
94set -- fmc.img "$cf.UCODE_IMAGE.bin" fmc.hash "$cf.UCODE_HASH.bin" fmc.pubkey "$cf.UCODE_PKEY.bin" \
95 fmc.sig "$cf.UCODE_SIG.bin" bl.img "$cb.UCODE_IMAGE_PROD.bin"
96outs=
97while [ $# -ge 2 ]; do
98 [ -f "$2" ] || fail 2 "C output missing: $2"
99 printf 'fwprep wrote %s bytes=%s sha256=%s\n' "$1" "$(wc -c < "$2")" "$(sha256sum < "$2" | cut -d' ' -f1)" >> "$t/want.txt"
100 printf 'out %s bytes=%s sha256=%s\n' "$1" "$(wc -c < "$2")" "$(sha256sum < "$2" | cut -d' ' -f1)" >> "$t/outs.txt"
101 outs="$outs $1:$2"
102 shift 2
103done
104printf 'fwprep wrote %s\nfwprep RESULT OK\n' "$manifest" >> "$t/want.txt"
105
106sec() { sed -n "s/^section [0-9]* $1 type=[0-9]* offset=\([0-9]*\) size=\([0-9]*\)\$/offset=\1 size=\2/p" "$t/insp.txt"; }
107names='version bootloader_off bootloader_size bl_param_off bl_param_size elf_off elf_size app_version manifest_off manifest_size mdata_off mdata_size mcode_off mcode_size monitor_enabled swbrom_code_off swbrom_code_size swbrom_data_off swbrom_data_size fb_reserved signed_as_code'
108words=$(od -An -v -tu4 "$cb.UCODE_DESC_PROD.bin")
109[ "$(echo $words | wc -w)" -eq 21 ] || fail 2 "C descriptor is not 21 words"
110desc=$(set -- $words; for n in $names; do printf ' %s=%s' "$n" "$1"; shift; done)
111{
112 echo "fwmanifest 1"
113 echo "fwversion $(sed -n 's/^fwversion //p' "$t/insp.txt")"
114 echo "build_id $(sed -n 's/^build_id //p' "$t/insp.txt")"
115 echo "fw_file bytes=$(wc -c < "$FW") sha256=$(sed -n 's/^sha256_file //p' "$t/insp.txt")"
116 echo "fwimage $(sec '\.fwimage') sha256=$(sed -n 's/^sha256_fwimage \([0-9a-f]*\) .*/\1/p' "$t/insp.txt")"
117 echo "fwsignature .fwsignature_$family $(sec "\.fwsignature_$family") sha256=$(sed -n 's/^sha256_signature //p' "$t/insp.txt")"
118 echo "fmc_src $FMC_C bytes=$(wc -c < "$G/$FMC_C") sha256=$FMC_C_SHA"
119 echo "boot_src $BOOT_C bytes=$(wc -c < "$G/$BOOT_C") sha256=$BOOT_C_SHA"
120 echo "bl_desc UCODE_DESC_PROD$desc"
121 cat "$t/outs.txt"
122 echo end
123} > "$t/manifest.want"
124
125o=$t/out
126if [ "$chip" = GB10B ]; then
127 mkdir "$o"
128 echo stale > "$o/$manifest"
129fi
130run_profile() {
131 if [ "$chip" = GB20B ]; then
132 run "$t/fwprep" "$@" gb20b
133 else
134 run "$t/fwprep" "$@"
135 fi
136}
137run_profile "$FW" "$OGKM" "$o" > "$t/om.txt" 2> "$t/om.err"
138rc=$?
139[ "$rc" -eq 0 ] || { cat "$t/om.err"; tail -n 3 "$t/om.txt"; fail 1 "fwprep exit $rc on the real inputs"; }
140[ -s "$t/om.err" ] && fail 1 "fwprep wrote to stderr on success"
141n=$(wc -l < "$t/want.txt")
142if ! cmp -s "$t/want.txt" "$t/om.txt"; then
143 diff "$t/want.txt" "$t/om.txt" | head -n 6
144 fail 1 "stdout differs ($(diff "$t/want.txt" "$t/om.txt" | grep -c '^[<>]') differing lines; want $n)"
145fi
146for p in $outs; do
147 cmp -s "${p#*:}" "$o/${p%%:*}" || fail 1 "${p%%:*} differs from the C output"
148done
149if ! cmp -s "$t/manifest.want" "$o/$manifest"; then
150 diff "$t/manifest.want" "$o/$manifest" | head -n 6
151 fail 1 "fw.manifest differs from the one rebuilt from the C outputs"
152fi
153[ "$(ls "$o" | wc -l)" -eq 6 ] || fail 1 "OUTDIR holds other files: $(ls "$o" | tr '\n' ' ')"
154[ "$(sha256sum < "$o/fmc.img" | cut -d' ' -f1)" = "$FMC_IMG_SHA" ] || fail 1 "fmc.img sha256 pin"
155[ "$(wc -c < "$o/fmc.img")" -eq "$fmc_size" ] || fail 1 "fmc.img size pin"
156[ "$(sha256sum < "$o/bl.img" | cut -d' ' -f1)" = "$BL_IMG_SHA" ] || fail 1 "bl.img sha256 pin"
157[ "$(wc -c < "$o/bl.img")" -eq "$boot_size" ] || fail 1 "bl.img size pin"
158grep -qF "bl_desc UCODE_DESC_PROD $DESC_PIN " "$o/$manifest" || fail 1 "descriptor pin"
159echo "fw_diff: $chip positive PASS ($n stdout lines, 5 outputs and $manifest identical to the C referees)"
160
161# ---- negative controls ----
162# edit_line SRC LINE OLD NEW DST: replace line LINE (which must read OLD) with NEW; exactly once
163edit_line() {
164 awk -v n="$2" -v a="$3" -v b="$4" 'NR == n && $0 == a { print b; c++; next } { print } END { exit c == 1 ? 0 : 1 }' \
165 "$1" > "$5" || fail 2 "control edit did not apply at $1:$2"
166}
167# tree NAME FMCFILE BOOTFILE: a minimal OGKMSRC holding the two bindata files
168tree() {
169 mkdir -p "$t/$1/src/nvidia/generated"
170 cp "$2" "$t/$1/src/nvidia/generated/$FMC_C"
171 cp "$3" "$t/$1/src/nvidia/generated/$BOOT_C"
172}
173neg=0
174# refused NAME FWFILE OGKMSRC WANTPREFIXFILE LASTLINE: fwprep exits 2, prints the C prefix then LASTLINE,
175# leaves no fw.manifest (a stale one is removed)
176refused() {
177 d=$t/o_$1
178 mkdir -p "$d"
179 echo stale > "$d/fw.manifest"
180 run "$t/fwprep" "$2" "$3" "$d" > "$t/$1.om" 2> "$t/$1.err"
181 r=$?
182 [ "$r" -eq 2 ] || fail 1 "control $1: fwprep exit $r, want 2"
183 { cat "$4"; echo "$5"; } > "$t/$1.want"
184 cmp -s "$t/$1.want" "$t/$1.om" || { diff "$t/$1.want" "$t/$1.om" | head -n 4; fail 1 "control $1: stdout differs"; }
185 [ -e "$d/fw.manifest" ] && fail 1 "control $1: fw.manifest left behind"
186 neg=$((neg + 1))
187 echo "fw_diff: control $1 refused (exit 2): $(grep -h 'REFUSED' "$t/$1.want" | tail -n 2 | tr '\n' ' ')"
188}
189# cref NAME TOOLARGS...: the C referee must refuse (exit 2); its stdout goes to $t/NAME.c
190cref() {
191 nm=$1; shift
192 run "$@" > "$t/$nm.c"
193 r=$?
194 [ "$r" -eq 2 ] || fail 1 "control $nm: C referee exit $r, want 2"
195}
196
197if [ "$chip" = GB20B ]; then
198 # Keep the container parseable and keep the archives' extracted bytes valid.
199 # Only the selected input's digest changes. Each failure must precede publication.
200 expect_refusal() {
201 run_profile "$1" "$2" "$t/red-out" > "$t/red.log"
202 status=$?
203 [ "$status" = 2 ] && [ ! -e "$t/red-out" ] &&
204 tail -n1 "$t/red.log" | grep -Fxq "$3" || fail 1 "control $4: exit $status or wrong refusal"
205 echo "fw_diff: $chip refused $4"
206 }
207 cp "$FW" "$t/appended.bin" && printf x >> "$t/appended.bin" || fail 2 "copy firmware"
208 expect_refusal "$t/appended.bin" "$OGKM" "fwprep REFUSED GB20B input digest" firmware-digest
209 for archive in "$FMC_C" "$BOOT_C"; do
210 tree altered "$G/$FMC_C" "$G/$BOOT_C" || fail 2 "copy archives"
211 printf '\n' >> "$t/altered/src/nvidia/generated/$archive" || fail 2 "edit archive"
212 expect_refusal "$FW" "$t/altered" "fwprep REFUSED GB20B input digest" "$archive"
213 done
214 tree wrong "$G/g_bindata_kgspGetBinArchiveGspRmFmcGfwProdSigned_GB10B.c" "$G/$BOOT_C" || fail 2 "copy wrong family"
215 expect_refusal "$FW" "$t/wrong" "fwprep REFUSED unexpected function kgspGetBinArchiveGspRmFmcGfwProdSigned_GB10B in $FMC_C" cross-family
216 # The GB20B run claims a new directory before writing anything. A second run cannot alter it.
217 (cd "$o" && sha256sum ./*) > "$t/sealed"
218 run_profile "$FW" "$OGKM" "$o" > "$t/reuse.log"
219 [ "$?" = 3 ] && tail -n1 "$t/reuse.log" | grep -Fxq "fwprep FAILED makedir $o: File exists" || fail 1 "existing directory accepted"
220 (cd "$o" && sha256sum -c "$t/sealed") >/dev/null || fail 1 "existing package modified"
221 run "$t/fwprep" "$FW" "$OGKM" "$o" gb20b-extra > "$t/bad-profile.log" 2>&1
222 [ "$?" = 1 ] && grep -Fxq 'usage: fwprep FWFILE OGKMSRC OUTDIR [gb20b]' "$t/bad-profile.log" || fail 1 "unknown profile accepted"
223 echo "fw_diff: GB20B PASS (all five output files and manifest match, six negative controls)"
224 exit 0
225fi
226
227# 1 truncated firmware (ends inside .fwsignature_gb10y)
228head -c 74985600 "$FW" > "$t/trunc.bin"
229cref trunc "$t/ck_gsp_fw_inspect" inspect "$t/trunc.bin"
230refused trunc "$t/trunc.bin" "$OGKM" "$t/trunc.c" "fwprep REFUSED firmware"
231rm -f "$t/trunc.bin"
232# 2 .fwsignature_gb10y renamed to .fwsignature_gb10x in the section string table
233off=$(grep -obaF .fwsignature_gb10y "$FW" | cut -d: -f1)
234[ "$(echo "$off" | wc -l)" -eq 1 ] && [ -n "$off" ] || fail 2 "section name not found once"
235cp "$FW" "$t/ren.bin"
236printf x | dd of="$t/ren.bin" bs=1 seek=$((off + 17)) conv=notrunc 2> /dev/null
237cref ren "$t/ck_gsp_fw_inspect" inspect "$t/ren.bin"
238grep -q 'no signature section' "$t/ren.c" || fail 1 "control ren: C refused for another reason"
239refused ren "$t/ren.bin" "$OGKM" "$t/ren.c" "fwprep REFUSED firmware"
240rm -f "$t/ren.bin"
241# 3 CRC-32: UCODE_DESC_PROD trailer byte 0xb7 -> 0xb6
242edit_line "$G/$BOOT_C" 24717 ' 0x78, 0xf4, 0x01, 0x00, 0xb7, 0x2b, 0xc9, 0xc2, 0x54, 0x00, 0x00, 0x00,' \
243 ' 0x78, 0xf4, 0x01, 0x00, 0xb6, 0x2b, 0xc9, 0xc2, 0x54, 0x00, 0x00, 0x00,' "$t/crc.c.in"
244tree crc "$G/$FMC_C" "$t/crc.c.in"
245cref crcb "$t/ck_gsp_bindata_extract" extract "$t/crc/src/nvidia/generated/$BOOT_C"
246grep -q 'CRC-32 mismatch' "$t/crcb.c" || fail 1 "control crc: C refused for another reason"
247cat "$t/insp.txt" "$t/fmc.txt" "$t/crcb.c" > "$t/crc.c"
248refused crc "$FW" "$t/crc" "$t/crc.c" "fwprep REFUSED bindata $BOOT_C"
249# 4 deflate body: UCODE_DESC_PROD compressed byte 0x20 -> 0x30
250edit_line "$G/$BOOT_C" 24716 ' 0x63, 0x65, 0x20, 0x02, 0x70, 0x41, 0xf1, 0x32, 0x20, 0xde, 0x00, 0xc4, 0xbe, 0x4c, 0x0c, 0x8c,' \
251 ' 0x63, 0x65, 0x30, 0x02, 0x70, 0x41, 0xf1, 0x32, 0x20, 0xde, 0x00, 0xc4, 0xbe, 0x4c, 0x0c, 0x8c,' "$t/body.c.in"
252tree body "$G/$FMC_C" "$t/body.c.in"
253cref bodyb "$t/ck_gsp_bindata_extract" extract "$t/body/src/nvidia/generated/$BOOT_C"
254grep -q 'inflate' "$t/bodyb.c" || fail 1 "control body: C refused for another reason"
255cat "$t/insp.txt" "$t/fmc.txt" "$t/bodyb.c" > "$t/body.c"
256refused body "$FW" "$t/body" "$t/body.c" "fwprep REFUSED bindata $BOOT_C"
257# 5 hash mismatch: first UCODE_HASH byte 0x2f -> 0x2e
258edit_line "$G/$FMC_C" 12319 ' 0x2f, 0xb0, 0x24, 0x61, 0x26, 0x9a, 0x45, 0xd3, 0xd4, 0x6c, 0x7b, 0x01, 0x88, 0x07, 0xff, 0x06,' \
259 ' 0x2e, 0xb0, 0x24, 0x61, 0x26, 0x9a, 0x45, 0xd3, 0xd4, 0x6c, 0x7b, 0x01, 0x88, 0x07, 0xff, 0x06,' "$t/hash.c.in"
260tree hash "$t/hash.c.in" "$G/$BOOT_C"
261cref hashf "$t/ck_gsp_bindata_extract" extract "$t/hash/src/nvidia/generated/$FMC_C"
262grep -q 'UCODE_HASH is not SHA-384 of UCODE_IMAGE' "$t/hashf.c" || fail 1 "control hash: C refused for another reason"
263cat "$t/insp.txt" "$t/hashf.c" > "$t/hash.c"
264refused hash "$FW" "$t/hash" "$t/hash.c" "fwprep REFUSED bindata $FMC_C"
265# 6 wrong function: the boot file in the FMC slot (the C accepts it; fwprep's own check refuses)
266tree swap "$G/$BOOT_C" "$G/$BOOT_C"
267cat "$t/insp.txt" "$t/boot.txt" > "$t/swap.c"
268refused swap "$FW" "$t/swap" "$t/swap.c" "fwprep REFUSED unexpected function $BOOT_F in $FMC_C"
269# 7 missing FWFILE: exit 1 with the C's stderr line, nothing on stdout
270run "$t/ck_gsp_fw_inspect" inspect "$t/nofile" > /dev/null 2> "$t/nofile.cerr"
271run "$t/fwprep" "$t/nofile" "$OGKM" "$t/o_nofile" > "$t/nofile.om" 2> "$t/nofile.err"
272r=$?
273[ "$r" -eq 1 ] || fail 1 "control nofile: fwprep exit $r, want 1"
274[ -s "$t/nofile.om" ] && fail 1 "control nofile: stdout not empty"
275cmp -s "$t/nofile.cerr" "$t/nofile.err" || fail 1 "control nofile: stderr differs from the C"
276neg=$((neg + 1))
277# 8 OUTDIR is a regular file: every check passes, the first output write fails, exit 3, no manifest
278echo x > "$t/notdir"
279run "$t/fwprep" "$FW" "$OGKM" "$t/notdir" > "$t/notdir.om" 2> /dev/null
280r=$?
281[ "$r" -eq 3 ] || fail 1 "control notdir: fwprep exit $r, want 3"
282tail -n 1 "$t/notdir.om" | grep -q "^fwprep FAILED makedir $t/notdir: File exists\$\|^fwprep FAILED write $t/notdir/fmc.img: Not a directory\$" \
283 || fail 1 "control notdir: $(tail -n 1 "$t/notdir.om")"
284neg=$((neg + 1))
285# 9 usage
286run "$t/fwprep" "$FW" "$OGKM" > /dev/null 2> "$t/usage.err"
287r=$?
288[ "$r" -eq 1 ] || fail 1 "control usage: fwprep exit $r, want 1"
289grep -Fxq 'usage: fwprep FWFILE OGKMSRC OUTDIR [gb20b]' "$t/usage.err" || fail 1 "control usage: stderr"
290neg=$((neg + 1))
291echo "fw_diff: PASS ($n stdout lines and 6 files identical to the C referees; $neg/9 negative controls refused)"
292sh "$0" gb20b || exit $?