From 73b46e1812ef20923ddf66f9db19dfb409c1f903 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Sat, 7 Mar 2020 23:34:32 +0100 Subject: [PATCH] coverage.sh: add test that makes sure that TMPDIR is used and works in unshare mode --- coverage.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/coverage.sh b/coverage.sh index c5d2968..75338c0 100755 --- a/coverage.sh +++ b/coverage.sh @@ -72,7 +72,7 @@ if [ ! -e shared/taridshift ] || [ taridshift -nt shared/taridshift ]; then fi starttime= -total=140 +total=141 skipped=0 runtests=0 i=1 @@ -635,6 +635,35 @@ else skipped=$((skipped+1)) fi +print_header "mode=unshare,variant=apt: custom TMPDIR" +cat << END > shared/test.sh +#!/bin/sh +set -eu +export LC_ALL=C.UTF-8 +if [ ! -e /mmdebstrap-testenv ]; then + echo "this test modifies the system and should only be run inside a container" >&2 + exit 1 +fi +adduser --gecos user --disabled-password user +sysctl -w kernel.unprivileged_userns_clone=1 +homedir=\$(runuser -u user -- sh -c 'cd && pwd') +runuser -u user -- mkdir "\$homedir/tmp" +runuser -u user -- env TMPDIR="\$homedir/tmp" $CMD --mode=unshare --variant=apt \ + --setup-hook='case "\$1" in "'"\$homedir/tmp/mmdebstrap."'"??????????) exit 0;; *) exit 1;; esac' \ + $DEFAULT_DIST /tmp/debian-chroot.tar $mirror +tar -tf /tmp/debian-chroot.tar | sort | diff -u tar1.txt - +# use rmdir as a quick check that nothing is remaining in TMPDIR +runuser -u user -- rmdir "\$homedir/tmp" +rm /tmp/debian-chroot.tar +END +if [ "$HAVE_QEMU" = "yes" ]; then + ./run_qemu.sh + runtests=$((runtests+1)) +else + echo "HAVE_QEMU != yes -- Skipping test..." >&2 + skipped=$((skipped+1)) +fi + print_header "mode=$defaultmode,variant=apt: test xz compressed tarball" cat << END > shared/test.sh #!/bin/sh