From e5bdcc8708ee571a7d7d54bbdfa7e226300344ea Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 5 Nov 2012 11:31:29 +0100 Subject: add testcase for the autoremove feature Conflicts: debian/apt.auto-removal.sh --- test/integration/test-kernel-helper-autoremove | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 test/integration/test-kernel-helper-autoremove (limited to 'test/integration/test-kernel-helper-autoremove') 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 < Date: Mon, 5 Nov 2012 11:39:47 +0100 Subject: also check that the running kernel is kept --- test/integration/test-kernel-helper-autoremove | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/integration/test-kernel-helper-autoremove') diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index a4c31283e..4c0571b13 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -28,6 +28,8 @@ 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\.\*" +# ... and also that the running kernel is exlucded +apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)\.\*" # done -msgpass \ No newline at end of file +msgpass -- cgit v1.2.3 From d27a691d72c8cc07767e92ae94bdfe391d9e9513 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Mon, 5 Nov 2012 12:32:50 -0800 Subject: typo fix --- test/integration/test-kernel-helper-autoremove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/integration/test-kernel-helper-autoremove') diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index 4c0571b13..52fa01bc5 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -28,7 +28,7 @@ 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\.\*" -# ... and also that the running kernel is exlucded +# ... and also that the running kernel is excluded apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)\.\*" # done -- cgit v1.2.3 From c6918c16c7b98fe709b4f7af5fa1c43f201fb1af Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Mon, 5 Nov 2012 13:11:39 -0800 Subject: Make the test more verbose and check for the negative case of a kernel that should not be marked not-for-autoremoval --- test/integration/test-kernel-helper-autoremove | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test/integration/test-kernel-helper-autoremove') diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index 52fa01bc5..37c1b6a43 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -25,11 +25,18 @@ install -m755 $TESTDIR/test-kernel-helper-autoremove.fake-dpkg $TMPDIR/fake-dpkg # run the helper sh ${TESTDIR}/../../debian/apt.auto-removal.sh +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 -apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic\.\*" +test -e $TMPDIR/apt.conf.d/01autoremove-kernels && msgpass || msgfail + +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 + # ... and also that the running kernel is excluded -apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)\.\*" +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 +# 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\.0-2-generic\.\*" && msgfail || msgpass # done -msgpass -- cgit v1.2.3 From d269b88d95686b77a170af203d0f4a7e44d28fc8 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Mon, 5 Nov 2012 14:44:59 -0800 Subject: Additional test for the case when installed version != newest version --- test/integration/test-kernel-helper-autoremove | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test/integration/test-kernel-helper-autoremove') diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index 37c1b6a43..ffcd3963a 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -23,7 +23,7 @@ export APT_CONFIG install -m755 $TESTDIR/test-kernel-helper-autoremove.fake-dpkg $TMPDIR/fake-dpkg # run the helper -sh ${TESTDIR}/../../debian/apt.auto-removal.sh +sh ${TESTDIR}/../../debian/apt.auto-removal.sh msgtest 'Check that kernel autoremoval list is correctly created' # and ensure its there, valid and version 10.0.0-1 is there too @@ -38,5 +38,18 @@ apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image- # 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\.0-2-generic\.\*" && msgfail || msgpass +apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic\.\*" && msgfail || 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 + # done -- cgit v1.2.3 From f2f53128c01f0620ab21c312cd6601d903aaae3c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 14 Feb 2014 22:01:35 +0100 Subject: fix the test-kernel-helper-autoremove testcase --- test/integration/test-kernel-helper-autoremove | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/integration/test-kernel-helper-autoremove') diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index ffcd3963a..2b165d100 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -30,22 +30,22 @@ msgtest 'Check that kernel autoremoval list is correctly created' test -e $TMPDIR/apt.conf.d/01autoremove-kernels && msgpass || msgfail 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 +apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-10.0.0-1-generic" && 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 +apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-$(uname -r)" && msgpass || msgfail # 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 +apt-config -c ${APT_CONFIG} dump|grep -q "APT::NeverAutoRemove::.*\^linux-image-1\.0\.01-2-generic" && msgfail || 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\.\*" +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 -- cgit v1.2.3