]> git.saurik.com Git - apt.git/blame - test/integration/test-no-fds-leaked-to-maintainer-scripts
correct architecture detection for 'rc' packages for purge
[apt.git] / test / integration / test-no-fds-leaked-to-maintainer-scripts
CommitLineData
0c787570
DK
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6
7setupenvironment
b8ef7ef4 8configarchitecture 'amd64' 'i386'
0c787570
DK
9configdpkgnoopchroot
10
150bdc9c 11setupsimplenativepackage "fdleaks" 'all' '1.0' 'unstable'
0c787570
DK
12BUILDDIR="incoming/fdleaks-1.0"
13for script in 'preinst' 'postinst' 'prerm' 'postrm'; do
14 echo '#!/bin/sh
15ls -l /proc/self/fd/' > ${BUILDDIR}/debian/$script
16done
17buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
18rm -rf "$BUILDDIR"
19
b8ef7ef4
DK
20PKGNAME='fdleaks:all'
21if ! dpkg-checkbuilddeps -d 'dpkg (>= 1.16.2)' /dev/null; then
22 PKGNAME='fdleaks'
23fi
24
0c787570
DK
25setupaptarchive
26
150bdc9c
DK
27rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
28testsuccess aptget install -y fdleaks -qq < /dev/null
0c787570
DK
29msgtest 'Check if fds were not' 'leaked'
30if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = '8' ]; then
31 msgpass
32else
33 echo
34 cat rootdir/tmp/testsuccess.output
35 msgfail
36fi
37
150bdc9c
DK
38cp rootdir/tmp/testsuccess.output terminal.output
39tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
40testfileequal 'terminal.log' "$(cat terminal.output)"
41
b8ef7ef4
DK
42testequal "startup archives unpack
43install $PKGNAME <none> 1.0
44status half-installed $PKGNAME 1.0
45status unpacked $PKGNAME 1.0
46status unpacked $PKGNAME 1.0
150bdc9c 47startup packages configure
b8ef7ef4
DK
48configure $PKGNAME 1.0 <none>
49status unpacked $PKGNAME 1.0
50status half-configured $PKGNAME 1.0
51status installed $PKGNAME 1.0" cut -f 3- -d' ' rootdir/var/log/dpkg.log
150bdc9c
DK
52
53rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
54testsuccess aptget purge -y fdleaks -qq
0c787570
DK
55msgtest 'Check if fds were not' 'leaked'
56if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = '12' ]; then
57 msgpass
58else
59 echo
60 cat rootdir/tmp/testsuccess.output
61 msgfail
62fi
150bdc9c
DK
63cp rootdir/tmp/testsuccess.output terminal.output
64tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
65testfileequal 'terminal.log' "$(cat terminal.output)"
66
b8ef7ef4
DK
67testequal "startup packages purge
68status installed $PKGNAME 1.0
69remove $PKGNAME 1.0 <none>
70status half-configured $PKGNAME 1.0
71status half-installed $PKGNAME 1.0
72status config-files $PKGNAME 1.0
73purge $PKGNAME 1.0 <none>
74status config-files $PKGNAME 1.0
75status config-files $PKGNAME 1.0
76status config-files $PKGNAME 1.0
77status config-files $PKGNAME 1.0
78status config-files $PKGNAME 1.0
79status not-installed $PKGNAME <none>" cut -f 3- -d' ' rootdir/var/log/dpkg.log