]> git.saurik.com Git - apt.git/commitdiff
add testcase for the autoremove feature
authorMichael Vogt <michael.vogt@ubuntu.com>
Mon, 5 Nov 2012 10:31:29 +0000 (11:31 +0100)
committerMichael Vogt <mvo@debian.org>
Fri, 14 Feb 2014 19:26:41 +0000 (20:26 +0100)
Conflicts:
debian/apt.auto-removal.sh

test/integration/test-kernel-helper-autoremove [new file with mode: 0755]
test/integration/test-kernel-helper-autoremove.fake-dpkg [new file with mode: 0644]

diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove
new file mode 100755 (executable)
index 0000000..a4c3128
--- /dev/null
@@ -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 (file)
index 0000000..aec6d44
--- /dev/null
@@ -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
+