Skip to content

Commit 6c09159

Browse files
committed
ci: run both downstream autopkgtests on all architectures via env-var path overrides
1 parent 9db65ab commit 6c09159

4 files changed

Lines changed: 36 additions & 101 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ jobs:
104104
ghostscript \
105105
poppler-utils \
106106
mupdf-tools \
107-
file \
108-
proot
107+
file
109108
110109
- name: Build & test libppd (native)
111110
if: matrix.use-qemu == false
@@ -132,9 +131,10 @@ jobs:
132131
run: |
133132
set -ex
134133
cd "$REPO_DIR"
135-
# Full downstream suite: libppd-2-dev (proot-free) +
136-
# libppd-2-ppd-handling (proot redirects /usr/bin/testppd and
137-
# /usr/share/ppd into the staging tree).
134+
# Full downstream suite: libppd-2-dev (compile/link/run) +
135+
# libppd-2-ppd-handling. Both point at the staged tree via
136+
# environment overrides, so no privilege or path redirection is
137+
# needed.
138138
make test-autopkgtest V=1
139139
140140
# -----------------------------------------------------------------------
@@ -199,11 +199,11 @@ jobs:
199199
exit 1
200200
}
201201
202-
# Downstream autopkgtest, proot-free leg only: nested proot under
203-
# QEMU-user emulation is unreliable, so the absolute-path PPD-
204-
# handling test runs on the native legs. The dev compile/link/run
205-
# test runs here.
206-
make test-autopkgtest-dev V=1
202+
# Full downstream autopkgtest suite. Both tests resolve the
203+
# staged build tree through environment overrides (no absolute
204+
# paths, no privilege, no bind mounts), so the same suite that
205+
# runs on the native legs runs unchanged under QEMU emulation.
206+
make test-autopkgtest V=1
207207
208208
# -----------------------------------------------------------------------
209209
# ARTIFACT UPLOAD (all four legs, only on failure)

Makefile.am

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,10 @@ stage-ciroot: all
434434

435435
# Common environment for the wrapper. PPDC_DATADIR / CUPS_DATADIR point ppdc
436436
# at the staged *.defs so `ppdc test.drv` resolves <font.defs> / <media.defs>
437-
# from the staging tree.
437+
# from the staging tree. LIBPPD_TESTPPD / LIBPPD_PPDDIR point the PPD-handling
438+
# test at the staged binary and data instead of the system /usr paths, so it
439+
# needs no absolute-path redirection (no root, no proot) and runs identically
440+
# on native and QEMU-emulated architectures.
438441
# NB: libppd configures with a split prefix (prefix=/ but exec_prefix=/usr and
439442
# everything installs under /usr), so the staging root the wrapper points at is
440443
# $(CIROOT)$(exec_prefix), not $(CIROOT)$(prefix).
@@ -443,33 +446,24 @@ CIROOT_ENV = \
443446
CIPREFIX="$(exec_prefix)" \
444447
TOP_BUILDDIR="$(abs_top_builddir)" \
445448
PPDC_DATADIR="$(CIROOT)$(datadir)/ppdc" \
446-
CUPS_DATADIR="$(CIROOT)$(datadir)"
447-
448-
# Absolute-path binds for the PPD-handling test (Fix C). Only these two host
449-
# paths are overlaid onto /usr; the rest of /usr is untouched.
450-
CIROOT_BINDS = \
451-
$(CIROOT)$(bindir)/testppd:/usr/bin/testppd \
452-
$(CIROOT)$(datadir)/ppd:/usr/share/ppd
449+
CUPS_DATADIR="$(CIROOT)$(datadir)" \
450+
LIBPPD_TESTPPD="$(CIROOT)$(bindir)/testppd" \
451+
LIBPPD_PPDDIR="$(CIROOT)$(datadir)/ppd/testppd"
453452

454453
# Full downstream suite in a single wrapper invocation, so the run produces one
455-
# aggregate PASS/FAIL summary across both tests. Both run under the /usr binds;
456-
# the dev test never touches the bound paths, so the binds are a no-op for it.
454+
# aggregate PASS/FAIL summary across both tests. Neither test needs privilege
455+
# or path redirection, so this is identical on every architecture.
457456
test-autopkgtest: stage-ciroot
458457
$(CIROOT_ENV) \
459-
AUTOPKGTEST_BINDS="$(CIROOT_BINDS)" \
460458
$(SHELL) $(srcdir)/ci/autopkgtest/run.sh libppd-2-dev libppd-2-ppd-handling
461459

462-
# Proot/bind-free leg: the dev compile/link/run test needs no /usr redirection
463-
# (used on the QEMU-emulated CI legs, where nested redirection is unreliable).
460+
# Single-test convenience targets (handy for debugging one case in isolation).
464461
test-autopkgtest-dev: stage-ciroot
465462
$(CIROOT_ENV) \
466463
$(SHELL) $(srcdir)/ci/autopkgtest/run.sh libppd-2-dev
467464

468-
# PPD-handling test only, under the staged /usr binds (handy for debugging the
469-
# redirection path in isolation).
470465
test-autopkgtest-ppd: stage-ciroot
471466
$(CIROOT_ENV) \
472-
AUTOPKGTEST_BINDS="$(CIROOT_BINDS)" \
473467
$(SHELL) $(srcdir)/ci/autopkgtest/run.sh libppd-2-ppd-handling
474468

475469
.PHONY: stage-ciroot install-test-programs install-test-data \

ci/autopkgtest/debian-tests/libppd-2-ppd-handling

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@ export HOME="$WORKDIR"
1313
export XDG_RUNTIME_DIR="$WORKDIR"
1414
trap 'cd /; rm -rf "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM
1515

16+
# Location of the installed test program and its PPD data. Default to the
17+
# system paths used when the package is installed (the normal Debian
18+
# autopkgtest case); allow a staged build tree to override them so the test
19+
# assumes no absolute paths and runs unprivileged on every architecture.
20+
: "${LIBPPD_TESTPPD:=/usr/bin/testppd}"
21+
: "${LIBPPD_PPDDIR:=/usr/share/ppd/testppd}"
22+
1623
# Copy test PPD files into right place
17-
cp -r /usr/share/ppd/testppd ppd
24+
cp -r "$LIBPPD_PPDDIR" ppd
1825
# Run the test program
19-
/usr/bin/testppd
26+
"$LIBPPD_TESTPPD"
2027
echo "run test program on system's $package: OK"

ci/autopkgtest/run.sh

Lines changed: 7 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,18 @@
66
# ($CIROOT) produced by `make stage-ciroot`, then runs the unmodified
77
# downstream scripts vendored under ci/autopkgtest/debian-tests/.
88
#
9-
# For libppd the PPD-handling test invokes the installed test binary and test
10-
# data through *absolute* paths (/usr/bin/testppd, /usr/share/ppd/testppd).
11-
# Those are redirected into the staging tree, surgically and reversibly, via
12-
# AUTOPKGTEST_BINDS (Fix C). Two backends are supported, chosen automatically:
13-
#
14-
# * mount --bind - when running as root or with passwordless sudo
15-
# (CI native runners). Real kernel bind mounts: robust
16-
# on every architecture, torn down on exit.
17-
# * proot - fallback when unprivileged (local dev): no root, no
18-
# host changes. (proot is ptrace-based and unreliable
19-
# under QEMU emulation and on some kernels, hence it is
20-
# only the fallback.)
9+
# The downstream scripts take environment overrides (e.g. LIBPPD_TESTPPD,
10+
# LIBPPD_PPDDIR) that default to the system /usr paths but can be redirected
11+
# into the staging tree. That keeps every test free of absolute-path
12+
# assumptions, so the wrapper needs no privilege and no bind mounts and runs
13+
# identically on native and QEMU-emulated architectures.
2114
#
2215
# Env in:
2316
# CIROOT staging root (default: $PWD/_ciroot)
2417
# CIPREFIX configured prefix (default: /usr)
2518
# TOP_BUILDDIR build tree (default: $PWD)
26-
# AUTOPKGTEST_BINDS optional space-separated "host:guest" binds for scripts
27-
# that read installed binaries/data via absolute paths.
28-
# Only the named paths are overlaid; the rest of the host
29-
# /usr (compiler, system libs) stays intact.
30-
# Any extra exported variables (e.g. PPDC_DATADIR, CUPS_DATADIR) are passed
31-
# straight through to the test scripts.
19+
# Any extra exported variables (e.g. PPDC_DATADIR, CUPS_DATADIR,
20+
# LIBPPD_TESTPPD, LIBPPD_PPDDIR) are passed straight through to the scripts.
3221
set -eu
3322

3423
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
@@ -52,61 +41,6 @@ LD_LIBRARY_PATH="$ROOT/lib${MULTIARCH:+:$ROOT/lib/$MULTIARCH}:$TOP_BUILDDIR/.lib
5241
PKG_CONFIG_PATH="$ROOT/lib/pkgconfig${MULTIARCH:+:$ROOT/lib/$MULTIARCH/pkgconfig}:$ROOT/share/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
5342
export PATH LD_LIBRARY_PATH PKG_CONFIG_PATH
5443

55-
# ---------------------------------------------------------------------------
56-
# Surgical /usr redirection (Fix C)
57-
# ---------------------------------------------------------------------------
58-
BIND_UNMOUNT=""
59-
BIND_RMDIRS=""
60-
cleanup_binds() {
61-
# Unmount in reverse and remove any placeholder targets we created.
62-
for m in $BIND_UNMOUNT; do $BIND_SUDO umount "$m" 2>/dev/null || true; done
63-
for d in $BIND_RMDIRS; do $BIND_SUDO rm -rf "$d" 2>/dev/null || true; done
64-
}
65-
66-
if [ -n "${AUTOPKGTEST_BINDS:-}" ] && [ -z "${_REDIR_DONE:-}" ]; then
67-
# Pick a privilege escalator for mount --bind, if available.
68-
BIND_SUDO=""
69-
have_priv=0
70-
if [ "$(id -u)" = 0 ]; then
71-
have_priv=1
72-
elif command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then
73-
BIND_SUDO="sudo"
74-
have_priv=1
75-
fi
76-
77-
if [ "$have_priv" = 1 ]; then
78-
trap cleanup_binds EXIT INT TERM
79-
for pair in $AUTOPKGTEST_BINDS; do
80-
src=${pair%%:*}
81-
dst=${pair#*:}
82-
if [ -d "$src" ]; then
83-
if [ ! -e "$dst" ]; then $BIND_SUDO mkdir -p "$dst"; BIND_RMDIRS="$dst $BIND_RMDIRS"; fi
84-
else
85-
if [ ! -e "$dst" ]; then
86-
$BIND_SUDO mkdir -p "$(dirname "$dst")"
87-
$BIND_SUDO touch "$dst"
88-
BIND_RMDIRS="$dst $BIND_RMDIRS"
89-
fi
90-
fi
91-
$BIND_SUDO mount --bind "$src" "$dst"
92-
BIND_UNMOUNT="$dst $BIND_UNMOUNT"
93-
echo "run.sh: bound $src -> $dst (mount --bind)"
94-
done
95-
_REDIR_DONE=1
96-
elif command -v proot >/dev/null 2>&1; then
97-
binds=""
98-
for pair in $AUTOPKGTEST_BINDS; do binds="$binds -b $pair"; done
99-
_REDIR_DONE=1; export _REDIR_DONE
100-
echo "run.sh: redirecting via proot (unprivileged fallback)"
101-
# shellcheck disable=SC2086
102-
exec proot $binds "$0" "$@"
103-
else
104-
echo "run.sh: AUTOPKGTEST_BINDS set but neither root/passwordless-sudo" >&2
105-
echo "run.sh: (for mount --bind) nor proot is available." >&2
106-
exit 1
107-
fi
108-
fi
109-
11044
if [ "$#" -eq 0 ]; then
11145
echo "run.sh: usage: run.sh <test-name> [test-name...]" >&2
11246
exit 2

0 commit comments

Comments
 (0)