ci / mcdc (push) Successful in 34s
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 46s
ci / bench (push) Successful in 12s
ci / test (push) Successful in 9s
ci / test (pull_request) Successful in 24s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / patches-apply (pull_request) Successful in 21s
ci / prune-artifacts (push) Skipped
ci / patches-apply (push) Successful in 41s
ci / bench (pull_request) Successful in 6s
ci / mcdc (pull_request) Successful in 29s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 1m48s
ci / qemu-tools (push) Successful in 5m39s
ci / quality (pull_request) Successful in 1m44s
ci / badges (pull_request) Skipped
ci / qemu-tools (pull_request) Successful in 3m42s
ci / kernel-symbols (pull_request) Successful in 6m55s
CI's shellcheck 0.9.0 failed qemu-tools on #38: SC2015 on the `[ -f ] && [ = ] || { ... }` refusal in qemu_get_busybox (now an if), and SC2012 on the `ls | head` that picks a patch to edit in busybox-panel-test.sh (now find | sort | head). No behaviour change. Refs flare-edge#2210 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
186 lines
8.4 KiB
Bash
186 lines
8.4 KiB
Bash
#!/usr/bin/env bash
|
|
# Offline checks for the rig's panel BusyBox inputs (qemu/busybox/,
|
|
# qemu/build-busybox.sh, RIG_BUSYBOX in qemu/lib.sh), flare-edge#2210. No
|
|
# compiler, network or VM: the build helpers run against small stand-in files.
|
|
#
|
|
# bash qemu/tests/busybox-panel-test.sh
|
|
set -uo pipefail
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
QEMU_DIR="$(cd "$HERE/.." && pwd)"
|
|
REPO="$(cd "$QEMU_DIR/.." && pwd)"
|
|
BB_DIR="$QEMU_DIR/busybox"
|
|
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/bb-panel-test.XXXXXX")"
|
|
trap 'rm -rf "$SCRATCH"' EXIT
|
|
FAIL=0
|
|
pass() { printf '[PASS] %s\n' "$1"; }
|
|
fail() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
|
|
export LC_ALL=C
|
|
|
|
# shellcheck source=qemu/build-busybox.sh disable=SC1091
|
|
. "$QEMU_DIR/build-busybox.sh"
|
|
# The sourced script sets -e for its own run; these checks report each failure.
|
|
set +e
|
|
|
|
# 1. Every setting the image's applet patch makes is in the panel config.
|
|
PATCH="$REPO/luckfox-sdk-patches/buildroot/patches/0001-busybox-applets.patch"
|
|
missing="$(sed -n -e 's/^+\(CONFIG_[A-Za-z0-9_]*=.*\)$/\1/p' \
|
|
-e 's/^+\(# CONFIG_[A-Za-z0-9_]* is not set\)$/\1/p' "$PATCH" |
|
|
while IFS= read -r l; do grep -qxF -- "$l" "$BB_DIR/panel.config" || printf '%s\n' "$l"; done)"
|
|
n="$(grep -cE '^\+(CONFIG_|# CONFIG_)' "$PATCH")"
|
|
if [ "$n" -gt 0 ] && [ -z "$missing" ]; then
|
|
pass "panel.config carries all $n settings of the image's applet patch"
|
|
else
|
|
fail "panel.config lacks settings of $PATCH: ${missing:-none read}"
|
|
fi
|
|
|
|
# 2. The rig differs from the panel only in linking and name lookup.
|
|
got="$(grep -Ev '^(#|$)' "$BB_DIR/rig.fragment" | sed 's/=.*//' | sort | tr '\n' ' ')"
|
|
if [ "$got" = "CONFIG_STATIC CONFIG_USE_BB_PWD_GRP CONFIG_USE_BB_SHADOW " ]; then
|
|
pass "rig.fragment sets only STATIC, USE_BB_PWD_GRP and USE_BB_SHADOW"
|
|
else
|
|
fail "rig.fragment sets symbols beyond linking and name lookup: $got"
|
|
fi
|
|
|
|
# 3. Applying the fragment replaces exactly its symbols.
|
|
bb_apply_fragment "$BB_DIR/panel.config" "$BB_DIR/rig.fragment" > "$SCRATCH/rig.config"
|
|
d="$(diff <(bb_settings "$BB_DIR/panel.config") <(bb_settings "$SCRATCH/rig.config"))"
|
|
want_d="$(printf '%s\n' '< CONFIG_STATIC is not set' '< CONFIG_USE_BB_PWD_GRP is not set' \
|
|
'< CONFIG_USE_BB_SHADOW is not set' '> CONFIG_STATIC=y' '> CONFIG_USE_BB_PWD_GRP=y' \
|
|
'> CONFIG_USE_BB_SHADOW=y')"
|
|
if [ "$(grep -E '^[<>]' <<<"$d" | sort)" = "$want_d" ]; then
|
|
pass "the rig config is the panel config with the three fragment lines"
|
|
else
|
|
fail "the rig config differs from the panel config by: $d"
|
|
fi
|
|
printf 'CONFIG_A=y\n# CONFIG_B is not set\nCONFIG_C="x"\n' > "$SCRATCH/p.config"
|
|
printf '# note\nNOT_A_SYMBOL=y\n' > "$SCRATCH/bad.fragment"
|
|
if ! bb_apply_fragment "$SCRATCH/p.config" "$SCRATCH/bad.fragment" >/dev/null 2>"$SCRATCH/frag.err" &&
|
|
grep -q 'bad fragment line' "$SCRATCH/frag.err"; then
|
|
pass "a fragment line that is not CONFIG_* is refused"
|
|
else
|
|
fail "a bad fragment line was accepted"
|
|
fi
|
|
|
|
# 4. A Kconfig rewrite of any setting fails and names it.
|
|
cp "$SCRATCH/p.config" "$SCRATCH/same.config"
|
|
printf '#\n# a header\n' >> "$SCRATCH/same.config"
|
|
if bb_check_config "$SCRATCH/p.config" "$SCRATCH/same.config" 2>/dev/null; then
|
|
pass "a config that only gained comments passes the rewrite check"
|
|
else
|
|
fail "the rewrite check failed a config with the same settings"
|
|
fi
|
|
printf 'CONFIG_A=y\nCONFIG_C="x"\n' > "$SCRATCH/dropped.config"
|
|
if ! bb_check_config "$SCRATCH/p.config" "$SCRATCH/dropped.config" 2>"$SCRATCH/cfg.err" &&
|
|
grep -q 'CONFIG_B is not set' "$SCRATCH/cfg.err"; then
|
|
pass "a setting Kconfig dropped fails the rewrite check, named"
|
|
else
|
|
fail "a dropped setting passed the rewrite check"
|
|
fi
|
|
|
|
# 5. The applet check compares names, not install paths.
|
|
printf 'b\na\n' > "$SCRATCH/applets.txt"
|
|
printf '/bin/a\n/usr/sbin/b\n' > "$SCRATCH/ok.links"
|
|
printf '/bin/a\n/usr/sbin/b\n/usr/bin/timeout\n' > "$SCRATCH/extra.links"
|
|
if bb_check_applets "$SCRATCH/ok.links" "$SCRATCH/applets.txt" 2>/dev/null; then
|
|
pass "the same applets under install paths pass"
|
|
else
|
|
fail "matching applets failed the applet check"
|
|
fi
|
|
if ! bb_check_applets "$SCRATCH/extra.links" "$SCRATCH/applets.txt" 2>"$SCRATCH/app.err" &&
|
|
grep -q '> timeout' "$SCRATCH/app.err"; then
|
|
pass "an applet the panel lacks fails the applet check, named"
|
|
else
|
|
fail "an extra applet passed the applet check"
|
|
fi
|
|
|
|
# 6. The two bench fixtures agree: applets.txt is help.txt's applet list.
|
|
if [ -s "$BB_DIR/applets.txt" ] && [ -z "$(sort "$BB_DIR/applets.txt" | uniq -d)" ] &&
|
|
[ "$(sort "$BB_DIR/applets.txt")" = "$(sed -n 's/^== //p' "$BB_DIR/help.txt" | sort)" ]; then
|
|
pass "applets.txt ($(wc -l < "$BB_DIR/applets.txt") applets) matches help.txt"
|
|
else
|
|
fail "applets.txt and help.txt list different applets (or duplicates)"
|
|
fi
|
|
|
|
# 7. RIG_BUSYBOX refusals, before any download or build.
|
|
run_get() { (QEMU_DIR="$QEMU_DIR" OUT="$SCRATCH/out" qemu_get_busybox) >/dev/null 2>"$SCRATCH/get.err"; }
|
|
if ! RIG_BUSYBOX=bogus run_get && grep -q 'RIG_BUSYBOX must be multiarch or panel' "$SCRATCH/get.err"; then
|
|
pass "an unknown RIG_BUSYBOX is refused"
|
|
else
|
|
fail "an unknown RIG_BUSYBOX was accepted"
|
|
fi
|
|
|
|
# 7b. A prebuilt panel binary (a flow job without the cross compiler) is taken
|
|
# only with a .inputs equal to this tree's qemu_busybox_panel_inputs.
|
|
inputs="$(QEMU_DIR="$QEMU_DIR" qemu_busybox_panel_inputs)"
|
|
if [[ "$inputs" =~ ^[0-9a-f]{64}$ ]]; then
|
|
pass "qemu_busybox_panel_inputs is one sha256"
|
|
else
|
|
fail "qemu_busybox_panel_inputs gave '$inputs'"
|
|
fi
|
|
mkdir -p "$SCRATCH/pre"
|
|
printf 'stand-in\n' > "$SCRATCH/pre/bb"
|
|
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err" &&
|
|
grep -q "inputs 'missing'" "$SCRATCH/get.err"; then
|
|
pass "a prebuilt panel BUSYBOX without .inputs is refused"
|
|
else
|
|
fail "a prebuilt panel BUSYBOX without .inputs was accepted"
|
|
fi
|
|
printf '%s\n' "$(printf '%s' "$inputs" | tr '0-9a-f' '1-9a-f0')" > "$SCRATCH/pre/bb.inputs"
|
|
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err"; then
|
|
pass "a prebuilt panel BUSYBOX built from other inputs is refused"
|
|
else
|
|
fail "a prebuilt panel BUSYBOX with other inputs was accepted"
|
|
fi
|
|
printf '%s\n' "$inputs" > "$SCRATCH/pre/bb.inputs"
|
|
got_bb="$(RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" QEMU_DIR="$QEMU_DIR" OUT="$SCRATCH/out" \
|
|
bash -c '. "$QEMU_DIR/lib.sh"; set -euo pipefail; qemu_get_busybox >/dev/null; printf %s "$BB"' 2>"$SCRATCH/get.err")"
|
|
if [ "$got_bb" = "$SCRATCH/pre/bb" ] && [ ! -e "$SCRATCH/out/busybox-armv7l-panel" ]; then
|
|
pass "a prebuilt panel BUSYBOX with matching .inputs is used as is, nothing built"
|
|
else
|
|
fail "a prebuilt panel BUSYBOX with matching .inputs was not used (BB='$got_bb': $(cat "$SCRATCH/get.err"))"
|
|
fi
|
|
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/none" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err"; then
|
|
pass "a prebuilt panel BUSYBOX that does not exist is refused"
|
|
else
|
|
fail "a missing prebuilt panel BUSYBOX was accepted"
|
|
fi
|
|
# Every committed input file is in the inputs hash: a config edit changes it.
|
|
mkdir -p "$SCRATCH/qcopy"
|
|
cp -a "$QEMU_DIR/busybox" "$SCRATCH/qcopy/"
|
|
printf '# CONFIG_TIMEOUT is not set\n' >> "$SCRATCH/qcopy/busybox/panel.config"
|
|
other="$(QEMU_DIR="$SCRATCH/qcopy" qemu_busybox_panel_inputs)"
|
|
first_patch="$(find "$SCRATCH/qcopy/busybox/patches" -maxdepth 1 -type f -name '*.patch' | sort | head -n 1)"
|
|
printf 'x\n' >> "$first_patch"
|
|
other2="$(QEMU_DIR="$SCRATCH/qcopy" qemu_busybox_panel_inputs)"
|
|
if [ "$other" != "$inputs" ] && [ "$other2" != "$other" ]; then
|
|
pass "a panel.config or patch edit changes qemu_busybox_panel_inputs"
|
|
else
|
|
fail "qemu_busybox_panel_inputs ignored a panel.config or patch edit"
|
|
fi
|
|
|
|
# 8. No cross compiler: the build fails closed, it never falls back.
|
|
if ! CROSS_COMPILE=no-such-cross- OUT="$SCRATCH/out" bash "$QEMU_DIR/build-busybox.sh" >/dev/null 2>"$SCRATCH/cc.err" &&
|
|
grep -q 'no no-such-cross-gcc on PATH' "$SCRATCH/cc.err" && [ ! -e "$SCRATCH/out/busybox-armv7l-panel" ]; then
|
|
pass "a missing cross compiler fails the build with no binary"
|
|
else
|
|
fail "the build did not fail closed without a cross compiler"
|
|
fi
|
|
|
|
# 9. The Buildroot patches are there and every one is a patch.
|
|
np=0
|
|
for p in "$BB_DIR"/patches/*.patch; do
|
|
grep -q '^+++ ' "$p" || fail "$p has no diff"
|
|
np=$((np + 1))
|
|
done
|
|
if [ "$np" -eq 11 ]; then
|
|
pass "the 11 Buildroot 2025.02.8 busybox patches are present"
|
|
else
|
|
fail "expected 11 Buildroot busybox patches, found $np"
|
|
fi
|
|
|
|
if [ "$FAIL" -ne 0 ]; then
|
|
echo "busybox-panel: FAILED"
|
|
exit 1
|
|
fi
|
|
echo "busybox-panel: all checks passed"
|