diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2012-11-05 11:31:29 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2012-11-05 11:31:29 +0100 |
commit | 0b9f0e9bba678c3e5327a260faee96ea3a71df79 (patch) | |
tree | e2c6c0329ff310ae99e6d27fe19dc141715e048e | |
parent | c1719bdbe919ae5814cbcfe5afc3f04d3ccd7efb (diff) |
add testcase for the autoremove feature
-rw-r--r-- | debian/apt.auto-removal.sh | 3 | ||||
-rwxr-xr-x | test/integration/test-kernel-helper-autoremove | 33 | ||||
-rw-r--r-- | test/integration/test-kernel-helper-autoremove.fake-dpkg | 13 |
3 files changed, 47 insertions, 2 deletions
diff --git a/debian/apt.auto-removal.sh b/debian/apt.auto-removal.sh index 2094372df..e1b1c92d4 100644 --- a/debian/apt.auto-removal.sh +++ b/debian/apt.auto-removal.sh @@ -18,7 +18,6 @@ set -e # will overwrite the db when it exits. -# eval $(apt-config shell APT_CONF_D Dir::Etc::parts/d) test -n "${APT_CONF_D}" || APT_CONF_D="/etc/apt/apt.conf.d" config_file=${APT_CONF_D}/01autoremove-kernels @@ -39,7 +38,7 @@ version_test_gt () return "$?" } -list=$($DPKG -l 'linux-image-[0-9]*'|awk '/^ii/ { print $2 }' | sed -e's/linux-image-//') +list=$(${DPKG} -l 'linux-image-[0-9]*'|awk '/^ii/ { print $2 }' | sed -e's/linux-image-//') latest_version="" for i in $list; do diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove new file mode 100755 index 000000000..a4c31283e --- /dev/null +++ b/test/integration/test-kernel-helper-autoremove @@ -0,0 +1,33 @@ +#!/bin/sh + +set -e + +# setup testdir +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +TMPDIR=$(mktemp -d) +cd $TMPDIR +addtrap "cd /; rm -rf $TMPDIR" + +# create mock environment +mkdir apt.conf.d +cat > aptconfig.conf <<EOF +Dir::Etc::parts "$TMPDIR/apt.conf.d"; +Dir::bin::dpkg "$TMPDIR/fake-dpkg"; +EOF +APT_CONFIG=aptconfig.conf +export APT_CONFIG + +# install fake-dpkg into it +install -m755 $TESTDIR/test-kernel-helper-autoremove.fake-dpkg $TMPDIR/fake-dpkg + +# run the helper +sh ${TESTDIR}/../../debian/apt.auto-removal.sh + +# and ensure its there, valid and version 10.0.0-1 is there too +test -e $TMPDIR/apt.conf.d/01autoremove-kernels +apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic\.\*" + +# done +msgpass
\ No newline at end of file diff --git a/test/integration/test-kernel-helper-autoremove.fake-dpkg b/test/integration/test-kernel-helper-autoremove.fake-dpkg new file mode 100644 index 000000000..aec6d4418 --- /dev/null +++ b/test/integration/test-kernel-helper-autoremove.fake-dpkg @@ -0,0 +1,13 @@ +#!/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-3.5.0-17-generic 3.5.0-17 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 + |