Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions scripts/pkg-proof.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,50 @@
# Arch /updates); the check is "modprobe -n resolves OUR file", not a fixed path.
set -uo pipefail

fam=${1:?usage: pkg-proof.sh <deb|rpm|arch> <package-dir>}
pkgdir=${2:?usage: pkg-proof.sh <deb|rpm|arch> <package-dir>}
pkgdir=$(cd "$pkgdir" && pwd)
fail=0
krel= # set by the kernel-package block; empty on the distribution-kernel path (no kernel packages)
rows=0 # how many rows this run printed, so the summary states a number instead of an adjective
row() { # <PASS|FAIL> <what> <detail>
printf '%-4s %-46s %s\n' "$1" "$2" "$3"
rows=$((rows + 1))
[ "$1" = PASS ] || fail=1
}
check() { local what=$1 detail=$2; shift 2; if "$@" >/dev/null 2>&1; then row PASS "$what" "$detail"; else row FAIL "$what" "$detail"; fi; }
# The sentence a document cites, defined HERE rather than typed at the end of the run and again in the
# self-test: the first version of the test re-typed it, so editing the real one left the test green
# (pi-release's second review of #1538, measured by mutating the summary line).
summary() { # <family>
if [ "$fail" = 0 ]; then echo "== $1: ALL ROWS PASS ($rows rows)"
else echo "== $1: FAILURES ABOVE ($rows rows)"; fi
}

# --self-test exercises the row/summary accounting on stubs and exits: the counter this run prints is only worth
# something if it has been seen to count, in both directions, without four containers. Same rule as the guard audits -
# a number nobody has watched move is a claim.
if [ "${1:-}" = --self-test ]; then
# This branch calls the SHIPPED row() and check(), not copies: the first version of the test defined its own row(), so
# dropping the increment from the real one would have left the test green - a check that cannot fail, in exactly the
# direction this PR exists to fix (pi-release's review of #1538). The definitions sit ABOVE this branch for that reason.
row PASS "a passing row counts" "1"
row PASS "a second passing row counts" "2"
[ "$rows" = 2 ] && [ "$fail" = 0 ] || { echo "self-test: FAIL - two passes should be 2 rows and no failure (rows=$rows fail=$fail)"; exit 1; }
row FAIL "a failing row counts too" "3"
[ "$rows" = 3 ] && [ "$fail" = 1 ] || { echo "self-test: FAIL - a failure should be the 3rd row and set fail (rows=$rows fail=$fail)"; exit 1; }
check "check() routes through row()" "stub" true
[ "$rows" = 4 ] || { echo "self-test: FAIL - check() should have counted a 4th row (rows=$rows)"; exit 1; }
s=$(summary selftest)
[ "$s" = "== selftest: FAILURES ABOVE (4 rows)" ] || { echo "self-test: FAIL - summary() reads '$s'"; exit 1; }
# and the passing branch of the same function, after clearing the failure flag
fail=0; s=$(summary selftest)
[ "$s" = "== selftest: ALL ROWS PASS (4 rows)" ] || { echo "self-test: FAIL - passing summary() reads '$s'"; exit 1; }
fail=1
echo "pkg-proof self-test: ok (4 rows through the shipped row()/check(); summary() '== selftest: FAILURES ABOVE (4 rows)')"
exit 0
fi

fam=${1:?usage: pkg-proof.sh <deb|rpm|arch> <package-dir>}
pkgdir=${2:?usage: pkg-proof.sh <deb|rpm|arch> <package-dir>}
pkgdir=$(cd "$pkgdir" && pwd)

# the kernel whose headers this container has (never the running kernel's)
case $fam in
Expand Down Expand Up @@ -409,5 +443,8 @@ if [ "$fam" = coexist ]; then
fi

echo
if [ "$fail" = 0 ]; then echo "== $fam: ALL ROWS PASS"; else echo "== $fam: FAILURES ABOVE"; fi
# The count travels WITH the verdict (engine#1522 review): every table that quotes these families is a derived count -
# `grep -c` over a log or a human counting - and a derived count drifts one merge at a time. Printing it here makes the
# document cite the harness's own sentence, the same shape as the appliance check's "RESULT: PASS (30 checks)".
summary "$fam"
exit "$fail"
Loading