summaryrefslogtreecommitdiff
path: root/test/integration/test-no-fds-leaked-to-maintainer-scripts
blob: 3c6457cabbbd4a6d026fab8bbc57930dd3c9da04 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
set -e

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework

setupenvironment
configarchitecture 'native'
configdpkgnoopchroot

setupsimplenativepackage "fdleaks" 'all' '1.0' 'unstable'
BUILDDIR="incoming/fdleaks-1.0"
for script in 'preinst' 'postinst' 'prerm' 'postrm'; do
	echo '#!/bin/sh
ls -l /proc/self/fd/' > ${BUILDDIR}/debian/$script
done
buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
rm -rf "$BUILDDIR"

setupaptarchive

rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
testsuccess aptget install -y fdleaks -qq < /dev/null
msgtest 'Check if fds were not' 'leaked'
if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = '8' ]; then
	msgpass
else
	echo
	cat rootdir/tmp/testsuccess.output
	msgfail
fi

cp rootdir/tmp/testsuccess.output terminal.output
tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
testfileequal 'terminal.log' "$(cat terminal.output)"

testequal 'startup archives unpack
install fdleaks:all <none> 1.0
status half-installed fdleaks:all 1.0
status unpacked fdleaks:all 1.0
status unpacked fdleaks:all 1.0
startup packages configure
configure fdleaks:all 1.0 <none>
status unpacked fdleaks:all 1.0
status half-configured fdleaks:all 1.0
status installed fdleaks:all 1.0' cut -f 3- -d' ' rootdir/var/log/dpkg.log

rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
testsuccess aptget purge -y fdleaks -qq
msgtest 'Check if fds were not' 'leaked'
if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = '12' ]; then
	msgpass
else
	echo
	cat rootdir/tmp/testsuccess.output
	msgfail
fi
cp rootdir/tmp/testsuccess.output terminal.output
tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
testfileequal 'terminal.log' "$(cat terminal.output)"

testequal 'startup packages purge
status installed fdleaks:all 1.0
remove fdleaks:all 1.0 <none>
status half-configured fdleaks:all 1.0
status half-installed fdleaks:all 1.0
status config-files fdleaks:all 1.0
purge fdleaks:all 1.0 <none>
status config-files fdleaks:all 1.0
status config-files fdleaks:all 1.0
status config-files fdleaks:all 1.0
status config-files fdleaks:all 1.0
status config-files fdleaks:all 1.0
status not-installed fdleaks:all <none>' cut -f 3- -d' ' rootdir/var/log/dpkg.log