]> git.saurik.com Git - apt.git/blame - test/integration/test-no-fds-leaked-to-maintainer-scripts
fix PTY interaction on linux and kfreebsd
[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
8configarchitecture 'native'
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
20setupaptarchive
21
150bdc9c
DK
22rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
23testsuccess aptget install -y fdleaks -qq < /dev/null
0c787570
DK
24msgtest 'Check if fds were not' 'leaked'
25if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = '8' ]; then
26 msgpass
27else
28 echo
29 cat rootdir/tmp/testsuccess.output
30 msgfail
31fi
32
150bdc9c
DK
33cp rootdir/tmp/testsuccess.output terminal.output
34tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
35testfileequal 'terminal.log' "$(cat terminal.output)"
36
37testequal 'startup archives unpack
38install fdleaks:all <none> 1.0
39status half-installed fdleaks:all 1.0
40status unpacked fdleaks:all 1.0
41status unpacked fdleaks:all 1.0
42startup packages configure
43configure fdleaks:all 1.0 <none>
44status unpacked fdleaks:all 1.0
45status half-configured fdleaks:all 1.0
46status installed fdleaks:all 1.0' cut -f 3- -d' ' rootdir/var/log/dpkg.log
47
48rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
49testsuccess aptget purge -y fdleaks -qq
0c787570
DK
50msgtest 'Check if fds were not' 'leaked'
51if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = '12' ]; then
52 msgpass
53else
54 echo
55 cat rootdir/tmp/testsuccess.output
56 msgfail
57fi
150bdc9c
DK
58cp rootdir/tmp/testsuccess.output terminal.output
59tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
60testfileequal 'terminal.log' "$(cat terminal.output)"
61
62testequal 'startup packages purge
63status installed fdleaks:all 1.0
64remove fdleaks:all 1.0 <none>
65status half-configured fdleaks:all 1.0
66status half-installed fdleaks:all 1.0
67status config-files fdleaks:all 1.0
68purge fdleaks:all 1.0 <none>
69status config-files fdleaks:all 1.0
70status config-files fdleaks:all 1.0
71status config-files fdleaks:all 1.0
72status config-files fdleaks:all 1.0
73status config-files fdleaks:all 1.0
74status not-installed fdleaks:all <none>' cut -f 3- -d' ' rootdir/var/log/dpkg.log