summaryrefslogtreecommitdiff
path: root/test/integration/test-kernel-helper-autoremove
blob: 37c1b6a436ed0a17ef31f5ab96b8de7cef22dc7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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

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

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
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