Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8d9d541fe |
@@ -237,9 +237,7 @@ jobs:
|
|||||||
- name: QEMU busybox fetch regression tests
|
- name: QEMU busybox fetch regression tests
|
||||||
# Retry on a bad sha256, the cached copy, and a server that answers
|
# Retry on a bad sha256, the cached copy, and a server that answers
|
||||||
# and then stalls (#1588), against local listeners: no network.
|
# and then stalls (#1588), against local listeners: no network.
|
||||||
run: |
|
run: bash qemu/tests/busybox-fetch.sh
|
||||||
bash qemu/tests/busybox-fetch.sh
|
|
||||||
bash qemu/tests/busybox-source-mirror.sh
|
|
||||||
- name: unpack-buildroot regression tests
|
- name: unpack-buildroot regression tests
|
||||||
# Fresh unpack, leave-existing-tree-alone, and every refusal path
|
# Fresh unpack, leave-existing-tree-alone, and every refusal path
|
||||||
# (unpatched selectors, bad tarball, half-present tree, failed
|
# (unpatched selectors, bad tarball, half-present tree, failed
|
||||||
|
|||||||
@@ -121,8 +121,7 @@ bb_main() {
|
|||||||
rm -f "$bin.inputs"
|
rm -f "$bin.inputs"
|
||||||
|
|
||||||
tar="${BB_SRC_TARBALL:-$out/busybox-${BB_SRC_VER}.tar.bz2}"
|
tar="${BB_SRC_TARBALL:-$out/busybox-${BB_SRC_VER}.tar.bz2}"
|
||||||
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source" \
|
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source"
|
||||||
"$BB_SRC_MIRROR_URL"
|
|
||||||
|
|
||||||
scratch="$(mktemp -d "${TMPDIR:-/tmp}/warden-busybox.XXXXXX")"
|
scratch="$(mktemp -d "${TMPDIR:-/tmp}/warden-busybox.XXXXXX")"
|
||||||
# Expanded now on purpose: the trap must remove this run's directory.
|
# Expanded now on purpose: the trap must remove this run's directory.
|
||||||
|
|||||||
+1
-8
@@ -11,9 +11,6 @@ BB_SRC_VER=1.37.0
|
|||||||
# Read by build-busybox.sh, which sources this file.
|
# Read by build-busybox.sh, which sources this file.
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
BB_SRC_URL="https://busybox.net/downloads/busybox-${BB_SRC_VER}.tar.bz2"
|
BB_SRC_URL="https://busybox.net/downloads/busybox-${BB_SRC_VER}.tar.bz2"
|
||||||
# Buildroot mirrors this exact pinned release; verification is unchanged.
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
BB_SRC_MIRROR_URL="https://sources.buildroot.net/busybox/busybox-${BB_SRC_VER}.tar.bz2"
|
|
||||||
BB_SRC_SHA256=3311dff32e746499f4df0d5df04d7eb396382d7e108bb9250e7b519b837043a4
|
BB_SRC_SHA256=3311dff32e746499f4df0d5df04d7eb396382d7e108bb9250e7b519b837043a4
|
||||||
|
|
||||||
qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
||||||
@@ -21,10 +18,9 @@ qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
|||||||
# Download URL to DEST and verify it against the sha256 WANT. A DEST that
|
# Download URL to DEST and verify it against the sha256 WANT. A DEST that
|
||||||
# already matches is kept. FAILS CLOSED: three bounded attempts, then exit 1;
|
# already matches is kept. FAILS CLOSED: three bounded attempts, then exit 1;
|
||||||
# a mismatching download never lands at DEST.
|
# a mismatching download never lands at DEST.
|
||||||
# Usage: qemu_fetch_verified URL WANT DEST LABEL [MIRROR_URL]
|
# Usage: qemu_fetch_verified URL WANT DEST LABEL
|
||||||
qemu_fetch_verified() {
|
qemu_fetch_verified() {
|
||||||
local url="$1" want="$2" dest="$3" label="$4" got
|
local url="$1" want="$2" dest="$3" label="$4" got
|
||||||
local mirror="${5:-}"
|
|
||||||
if [ -f "$dest" ]; then
|
if [ -f "$dest" ]; then
|
||||||
got="$(sha256sum "$dest" | awk '{print $1}')"
|
got="$(sha256sum "$dest" | awk '{print $1}')"
|
||||||
if [ "$want" = "$got" ]; then
|
if [ "$want" = "$got" ]; then
|
||||||
@@ -44,9 +40,6 @@ qemu_fetch_verified() {
|
|||||||
local attempt tmp="${dest}.download.$$"
|
local attempt tmp="${dest}.download.$$"
|
||||||
rm -f "$tmp"
|
rm -f "$tmp"
|
||||||
for attempt in 1 2 3; do
|
for attempt in 1 2 3; do
|
||||||
if [ "$attempt" -gt 1 ] && [ -n "$mirror" ]; then
|
|
||||||
url="$mirror"
|
|
||||||
fi
|
|
||||||
qemu_log "downloading $url (attempt $attempt/3)"
|
qemu_log "downloading $url (attempt $attempt/3)"
|
||||||
if curl --retry 1 --retry-delay "$delay" --retry-connrefused \
|
if curl --retry 1 --retry-delay "$delay" --retry-connrefused \
|
||||||
--connect-timeout "$stall" --speed-limit 1024 --speed-time "$stall" \
|
--connect-timeout "$stall" --speed-limit 1024 --speed-time "$stall" \
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# The sourced downloader runs before the later production-call test stub.
|
|
||||||
# shellcheck disable=SC2218
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
QEMU_DIR="$(cd "$TEST_DIR/.." && pwd)"
|
|
||||||
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/busybox-source-mirror.XXXXXX")"
|
|
||||||
trap 'rm -rf "$SCRATCH"' EXIT
|
|
||||||
|
|
||||||
mkdir -p "$SCRATCH/bin"
|
|
||||||
printf 'pinned source fixture' > "$SCRATCH/good"
|
|
||||||
WANT="$(sha256sum "$SCRATCH/good" | awk '{print $1}')"
|
|
||||||
export MIRROR_LOG="$SCRATCH/requests" MIRROR_GOOD="$SCRATCH/good"
|
|
||||||
export MIRROR_MODE=good
|
|
||||||
cat > "$SCRATCH/bin/curl" <<'CURL'
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
url= out=
|
|
||||||
while [ "$#" -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
-o) shift; out="$1" ;;
|
|
||||||
https://*) url="$1" ;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
printf '%s\n' "$url" >> "$MIRROR_LOG"
|
|
||||||
[ -n "$out" ] || exit 2
|
|
||||||
case "$url" in
|
|
||||||
https://primary.invalid/source) exit 28 ;;
|
|
||||||
https://mirror.invalid/source)
|
|
||||||
if [ "$MIRROR_MODE" = good ]; then cp "$MIRROR_GOOD" "$out";
|
|
||||||
else printf 'corrupt mirror response' > "$out"; fi ;;
|
|
||||||
*) exit 2 ;;
|
|
||||||
esac
|
|
||||||
CURL
|
|
||||||
chmod 0755 "$SCRATCH/bin/curl"
|
|
||||||
export PATH="$SCRATCH/bin:$PATH"
|
|
||||||
# shellcheck source=qemu/lib.sh disable=SC1091
|
|
||||||
source "$QEMU_DIR/lib.sh"
|
|
||||||
|
|
||||||
qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
|
||||||
"$SCRATCH/fetched" source https://mirror.invalid/source
|
|
||||||
cmp "$SCRATCH/good" "$SCRATCH/fetched"
|
|
||||||
printf '%s\n' https://primary.invalid/source https://mirror.invalid/source > "$SCRATCH/expected"
|
|
||||||
cmp "$MIRROR_LOG" "$SCRATCH/expected"
|
|
||||||
echo 'PASS primary timeout uses verified mirror'
|
|
||||||
|
|
||||||
: > "$MIRROR_LOG"
|
|
||||||
qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
|
||||||
"$SCRATCH/fetched" source https://mirror.invalid/source
|
|
||||||
test ! -s "$MIRROR_LOG"
|
|
||||||
echo 'PASS verified cache avoids both sources'
|
|
||||||
|
|
||||||
export MIRROR_MODE=bad
|
|
||||||
: > "$MIRROR_LOG"
|
|
||||||
if (qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
|
||||||
"$SCRATCH/refused" source https://mirror.invalid/source) > "$SCRATCH/refusal" 2>&1; then
|
|
||||||
echo 'FAIL corrupt mirror was accepted' >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
test "$(wc -l < "$MIRROR_LOG")" -eq 3
|
|
||||||
test ! -e "$SCRATCH/refused"
|
|
||||||
test -z "$(find "$SCRATCH" -maxdepth 1 -name 'refused.download.*' -print -quit)"
|
|
||||||
grep -q 'after 3 verified attempts' "$SCRATCH/refusal"
|
|
||||||
echo 'PASS corrupt mirror refused within three attempts'
|
|
||||||
|
|
||||||
# Exercise the production source call with the downloader intercepted only
|
|
||||||
# after build-busybox.sh loads its constants. Refuse before extraction.
|
|
||||||
# shellcheck source=qemu/build-busybox.sh disable=SC1091
|
|
||||||
source "$QEMU_DIR/build-busybox.sh"
|
|
||||||
mkdir -p "$SCRATCH/toolchain"
|
|
||||||
printf '#!/bin/sh\nexit 0\n' > "$SCRATCH/toolchain/fake-gcc"
|
|
||||||
chmod 0755 "$SCRATCH/toolchain/fake-gcc"
|
|
||||||
qemu_fetch_verified() {
|
|
||||||
[ "$1" = "$BB_SRC_URL" ] && [ "$2" = "$BB_SRC_SHA256" ]
|
|
||||||
[ "$5" = "$BB_SRC_MIRROR_URL" ]
|
|
||||||
printf '%s\n' 'production mirror call verified' > "$SCRATCH/wired"
|
|
||||||
return 42
|
|
||||||
}
|
|
||||||
set +e
|
|
||||||
(set -e; OUT="$SCRATCH/build" CROSS_COMPILE="$SCRATCH/toolchain/fake-" JOBS=1 bb_main) \
|
|
||||||
> "$SCRATCH/wiring-log" 2>&1
|
|
||||||
status=$?
|
|
||||||
set -e
|
|
||||||
if [ "$status" -ne 42 ]; then
|
|
||||||
cat "$SCRATCH/wiring-log" >&2
|
|
||||||
echo 'FAIL production source call did not stop at the verified downloader' >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
grep -qx 'production mirror call verified' "$SCRATCH/wired"
|
|
||||||
echo 'PASS production source fetch supplies pinned mirror'
|
|
||||||
Reference in New Issue
Block a user