coverage.sh: add 7 more tests

This commit is contained in:
Johannes 'josch' Schauer 2019-02-23 08:46:32 +01:00
parent 7126feff41
commit 93cf0544c6
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -209,6 +209,21 @@ END
done done
done done
print_header "test --help"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
$CMD --help | grep --quiet SYNOPSIS
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
elif [ "$defaultmode" = "root" ]; then
./run_null.sh SUDO
else
./run_null.sh
fi
print_header "mode=root,variant=apt: create directory" print_header "mode=root,variant=apt: create directory"
cat << END > shared/test.sh cat << END > shared/test.sh
#!/bin/sh #!/bin/sh
@ -224,6 +239,24 @@ else
./run_null.sh SUDO ./run_null.sh SUDO
fi fi
print_header "mode=root,variant=apt: fail with unshare as root user"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
ret=0
$CMD --mode=unshare --variant=apt unstable /tmp/debian-unstable $mirror || ret=\$?
if [ "\$ret" = 0 ]; then
echo expected failure but got exit \$ret
exit 1
fi
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
else
echo "HAVE_QEMU != yes -- Skipping test..."
fi
print_header "mode=root,variant=apt: test progress bars on fake tty" print_header "mode=root,variant=apt: test progress bars on fake tty"
cat << END > shared/test.sh cat << END > shared/test.sh
#!/bin/sh #!/bin/sh
@ -240,6 +273,22 @@ else
./run_null.sh SUDO ./run_null.sh SUDO
fi fi
print_header "mode=root,variant=apt: test --debug output on fake tty"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
script -qfc "$CMD --mode=root --debug --variant=apt unstable /tmp/unstable-chroot.tar $mirror" /dev/null
tar -tf /tmp/unstable-chroot.tar | sort > tar2.txt
diff -u tar1.txt tar2.txt
rm /tmp/unstable-chroot.tar
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
else
./run_null.sh SUDO
fi
print_header "mode=root,variant=apt: existing empty directory" print_header "mode=root,variant=apt: existing empty directory"
cat << END > shared/test.sh cat << END > shared/test.sh
#!/bin/sh #!/bin/sh
@ -294,6 +343,24 @@ else
echo "HAVE_QEMU != yes -- Skipping test..." echo "HAVE_QEMU != yes -- Skipping test..."
fi fi
print_header "mode=root,variant=apt: fail with missing lz4"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
ret=0
$CMD --mode=root --variant=apt unstable /tmp/unstable-chroot.tar.lz4 $mirror || ret=\$?
if [ "\$ret" = 0 ]; then
echo expected failure but got exit \$ret
exit 1
fi
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
else
./run_null.sh SUDO
fi
print_header "mode=root,variant=apt: create tarball with /tmp mounted nodev" print_header "mode=root,variant=apt: create tarball with /tmp mounted nodev"
cat << END > shared/test.sh cat << END > shared/test.sh
#!/bin/sh #!/bin/sh
@ -444,6 +511,27 @@ else
./run_null.sh ./run_null.sh
fi fi
print_header "mode=$defaultmode,variant=apt: invalid mirror"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
ret=0
$CMD --mode=$defaultmode --variant=apt unstable /tmp/unstable-chroot.tar $mirror/invalid || ret=\$?
if [ "\$ret" = 0 ]; then
echo expected failure but got exit \$ret
exit 1
fi
rm /tmp/unstable-chroot.tar
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
elif [ "$defaultmode" = "root" ]; then
./run_null.sh SUDO
else
./run_null.sh
fi
print_header "mode=root,variant=apt: test --include=libc6:armhf" print_header "mode=root,variant=apt: test --include=libc6:armhf"
cat << END > shared/test.sh cat << END > shared/test.sh
#!/bin/sh #!/bin/sh
@ -608,6 +696,55 @@ else
./run_null.sh SUDO ./run_null.sh SUDO
fi fi
print_header "mode=root,variant=apt: test failing --customize-hook"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
ret=0
$CMD --mode=root --variant=apt --customize-hook='chroot "\$1" sh -c "exit 1"' unstable /tmp/debian-unstable $mirror || ret=\$?
if [ "\$ret" = 0 ]; then
echo expected failure but got exit \$ret
exit 1
fi
rm -r /tmp/debian-unstable
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
else
./run_null.sh SUDO
fi
print_header "mode=root,variant=apt: test sigint during --customize-hook"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
setsid --wait $CMD --mode=root --variant=apt --customize-hook='touch done && sleep 10 && touch fail' unstable /tmp/debian-unstable $mirror &
pid=\$!
while sleep 1; do [ -e done ] && break; done
rm done
pgid=\$(echo \$(ps -p \$pid -o pgid=))
/bin/kill --signal INT -- -\$pgid
ret=0
wait \$pid || ret=\$?
if [ -e fail ]; then
echo customize hook was not interrupted
rm fail
exit 1
fi
if [ "\$ret" = 0 ]; then
echo expected failure but got exit \$ret
exit 1
fi
rm -r /tmp/debian-unstable
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
else
./run_null.sh SUDO
fi
print_header "mode=root,variant=apt: debootstrap no-op options" print_header "mode=root,variant=apt: debootstrap no-op options"
cat << END > shared/test.sh cat << END > shared/test.sh
#!/bin/sh #!/bin/sh