summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-03-10 17:53:22 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-03-13 13:58:46 +0100
commitb9b0f6222c489db78331cc8be3c093538d22c70b (patch)
tree173f255d53371aad0846c3ccbeec44d321cfe838 /test
parent52922e2a6795aadcbb8dd11bba14db0f05da34c6 (diff)
use a configurable list of versioned kernel packages
With APT::VersionedKernelPackages users have the option of adding packages like pre-build out-of-tree modules to the list of automatically protected from being autoremoved.
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework10
-rwxr-xr-xtest/integration/test-kernel-helper-autoremove91
-rw-r--r--test/integration/test-kernel-helper-autoremove.fake-dpkg13
-rwxr-xr-xtest/integration/test-ubuntu-bug-1078697-missing-source-hashes (renamed from test/integration/test-bug-1078697-missing-source-hashes)0
4 files changed, 58 insertions, 56 deletions
diff --git a/test/integration/framework b/test/integration/framework
index c623e6231..dad8c99f0 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -93,14 +93,15 @@ msgdone() {
runapt() {
msgdebug "Executing: ${CCMD}$*${CDEBUG} "
- local CMD="$1"
+ local CMD="${BUILDDIRECTORY}/$1"
+ if [ "$1" = 'sh' ]; then CMD='sh'; fi
shift
if [ -f ./aptconfig.conf ]; then
- MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@"
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@"
elif [ -f ../aptconfig.conf ]; then
- MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@"
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@"
else
- MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@"
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${BUILDDIRECTORY} $CMD "$@"
fi
}
aptconfig() { runapt apt-config "$@"; }
@@ -198,6 +199,7 @@ setupenvironment() {
touch var/lib/dpkg/available
mkdir -p usr/lib/apt
ln -s ${METHODSDIR} usr/lib/apt/methods
+ ln -s ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove etc/apt/apt.conf.d/01autoremove
cd ..
local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove
index 2b165d100..be30c6f6e 100755
--- a/test/integration/test-kernel-helper-autoremove
+++ b/test/integration/test-kernel-helper-autoremove
@@ -1,55 +1,68 @@
#!/bin/sh
-
set -e
-# setup testdir
TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
+setupenvironment
+configarchitecture 'native'
-TMPDIR=$(mktemp -d)
-cd $TMPDIR
-addtrap "cd /; rm -rf $TMPDIR"
+# the executed script would use the installed apt-config,
+# which is outside of our control
+msgtest 'Check that the installed apt-config supports' '--no-empty'
+if apt-config dump --no-empty >/dev/null 2>&1; then
+ msgpass
+else
+ msgskip
+ exit 0
+fi
-# create mock environment
-mkdir apt.conf.d
-cat > aptconfig.conf <<EOF
-Dir::Etc::parts "$TMPDIR/apt.conf.d";
-Dir::bin::dpkg "$TMPDIR/fake-dpkg";
+# install fake-dpkg into it
+cat > ./fake-dpkg <<EOF
+#!/bin/sh
+set -e
+if [ "\$1" = "-l" ]; then
+ echo "ii linux-image-1.0.0-2-generic 1.0.0-2 amd64"
+ echo "ii linux-image-\$(uname -r) not-used amd64"
+ echo "ii linux-image-100.0.0-1-generic 100.0.0.1-1 amd64"
+else
+ dpkg "\$@"
+fi
EOF
-APT_CONFIG=aptconfig.conf
-export APT_CONFIG
+chmod +x ./fake-dpkg
+echo 'Dir::Bin::dpkg "./fake-dpkg";' > rootdir/etc/apt/apt.conf.d/99fakedpkg
-# install fake-dpkg into it
-install -m755 $TESTDIR/test-kernel-helper-autoremove.fake-dpkg $TMPDIR/fake-dpkg
+catfail() {
+ echo >&2
+ echo >&2 '### List of protected kernels:'
+ cat >&2 protected.list
+ msgfail
+}
-# run the helper
-sh ${TESTDIR}/../../debian/apt.auto-removal.sh
+testprotected() {
+ rm -f rootdir/etc/apt/apt.conf.d/01autoremove-kernels protected.list
-msgtest 'Check that kernel autoremoval list is correctly created'
-# and ensure its there, valid and version 10.0.0-1 is there too
-test -e $TMPDIR/apt.conf.d/01autoremove-kernels && msgpass || msgfail
+ testsuccess runapt sh ${TESTDIR}/../../debian/apt.auto-removal.sh "$@"
-msgtest 'Check that most recent kernel is saved from autoremoval'
-apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" && msgpass || msgfail
+ msgtest 'Check kernel autoremoval protection list' 'is created'
+ test -e rootdir/etc/apt/apt.conf.d/01autoremove-kernels && msgpass || msgfail
-# ... and also that the running kernel is excluded
-msgtest 'Check that running kernel is saved from autoremoval'
-apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" && msgpass || msgfail
+ msgtest 'Check kernel autoremoval protection list' 'can be dumped'
+ aptconfig dump --no-empty --format '%v%n' 'APT::NeverAutoRemove' >protected.list 2>&1 && msgpass || catfail
-# and that the old kernel is *not* excluded from autoremoval
-msgtest 'Check that older kernels are not excluded from autoremoval'
-apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic" && msgfail || msgpass
+ msgtest 'Check kernel autoremoval protection list' 'can be parsed'
+ grep -q '^[A-Z]: ' protected.list && catfail || msgpass
-msgtest "Check that the older kernel is retained when it's being installed"
-sh ${TESTDIR}/../../debian/apt.auto-removal.sh 1.0.01-2-generic
-test -e $TMPDIR/apt.conf.d/01autoremove-kernels
-if ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" \
- || ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" \
- || ! apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic"
-then
- msgfail
-else
- msgpass
-fi
+ msgtest 'Check kernel autoremoval protection list includes' 'most recent kernel'
+ grep -q '^\^linux-image-100\.0\.0-1-generic\$$' protected.list && msgpass || catfail
+
+ msgtest 'Check kernel autoremoval protection list includes' 'running kernel'
+ grep -q "^\\^linux-image-$(uname -r)\\\$\$" protected.list && msgpass || catfail
+}
+
+testprotected
+msgtest 'Check kernel autoremoval protection list does not include' 'old kernel'
+grep -q '^\^linux-image-1\.0\.0-2-generic\$$' protected.list && catfail || msgpass
-# done
+testprotected 1.0.0-2-generic
+msgtest 'Check kernel autoremoval protection list includes' 'installed kernel'
+grep -q '^\^linux-image-1\.0\.0-2-generic\$$' protected.list && msgpass || catfail
diff --git a/test/integration/test-kernel-helper-autoremove.fake-dpkg b/test/integration/test-kernel-helper-autoremove.fake-dpkg
deleted file mode 100644
index a365c5370..000000000
--- a/test/integration/test-kernel-helper-autoremove.fake-dpkg
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-set -e
-
-if [ "$1" = "-l" ]; then
- echo "ii linux-image-1.0.0-2-generic 1.0.01-2 amd64"
- echo "ii linux-image-$(uname -r) not-used amd64"
- echo "ii linux-image-10.0.0-1-generic 10.0.0.1-1 amd64"
-elif [ "$1" = "--compare-versions" ]; then
- dpkg "$1" "$2" "$3" "$4"
-else
- dpkg $@
-fi
-
diff --git a/test/integration/test-bug-1078697-missing-source-hashes b/test/integration/test-ubuntu-bug-1078697-missing-source-hashes
index 6fcb856b5..6fcb856b5 100755
--- a/test/integration/test-bug-1078697-missing-source-hashes
+++ b/test/integration/test-ubuntu-bug-1078697-missing-source-hashes