4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture 'amd64' 'i386'
11 setupsimplenativepackage "fdleaks
" 'all' '1.0' 'unstable'
12 BUILDDIR="incoming
/fdleaks
-1.0
"
13 for script in 'preinst' 'postinst' 'prerm' 'postrm'; do
14 cat > ${BUILDDIR}/debian/$script << EOF
16 if [ -e '$(pwd)/rootdir/tmp/read_stdin' ]; then
18 echo "STDIN
: -\
$line-"
23 buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
27 if ! dpkg-checkbuilddeps -d 'dpkg (>= 1.16.2)' /dev/null >/dev/null 2>&1; then
33 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
34 testsuccess aptget install -y fdleaks -qq < /dev/null
37 msgtest 'Check if fds were not' "leaked
: expect
$1"
38 if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = "$1" ]; then
42 cat rootdir/tmp/testsuccess.output
49 cp rootdir/tmp/testsuccess.output terminal.output
50 tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
51 testfileequal 'terminal.log' "$(cat terminal.output)"
53 testequal "startup archives unpack
54 install $PKGNAME <none
> 1.0
55 status half
-installed $PKGNAME 1.0
56 status unpacked
$PKGNAME 1.0
57 status unpacked
$PKGNAME 1.0
58 startup packages configure
59 configure
$PKGNAME 1.0 <none
>
60 status unpacked
$PKGNAME 1.0
61 status half
-configured $PKGNAME 1.0
62 status installed
$PKGNAME 1.0" cut -f 3- -d' ' rootdir/var/log/dpkg.log
66 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
67 testsuccess aptget purge -y fdleaks -qq
71 cp rootdir/tmp/testsuccess.output terminal.output
72 tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
73 testfileequal 'terminal.log' "$(cat terminal.output)"
75 testequal "startup packages remove
76 status installed
$PKGNAME 1.0
77 remove
$PKGNAME 1.0 <none
>
78 status half
-configured $PKGNAME 1.0
79 status half
-installed $PKGNAME 1.0
80 status config
-files $PKGNAME 1.0
81 status config
-files $PKGNAME 1.0
82 startup packages configure
83 startup packages purge
84 remove
$PKGNAME 1.0 <none
>
85 purge
$PKGNAME 1.0 <none
>
86 status config
-files $PKGNAME 1.0
87 status config
-files $PKGNAME 1.0
88 status config
-files $PKGNAME 1.0
89 status config
-files $PKGNAME 1.0
90 status config
-files $PKGNAME 1.0
91 status not
-installed $PKGNAME <none
>
92 startup packages configure
" cut -f 3- -d' ' rootdir/var/log/dpkg.log
93 testequalor2 "dpkg
-query: no packages found matching
${PKGNAME}" "No packages found matching
${PKGNAME}.
" dpkg -l "$PKGNAME"
97 msgtest 'setsid provided is new enough to support' '-w'
98 if dpkg-checkbuilddeps -d 'util-linux (>= 2.24.2-1)' /dev/null >/dev/null 2>&1; then
101 msgskip "$(command dpkg -l util-linux)"
105 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
106 testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt
-get" install -y fdleaks -qq < /dev/null
109 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
110 testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt
-get" purge -y fdleaks -qq
113 touch rootdir/tmp/read_stdin
115 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
116 for i in $(seq 1 10); do echo "$i"; done | testsuccess aptget install -y fdleaks -qq
118 testequal '2' grep -c '^STDIN: ' rootdir/var/log/apt/term.log
120 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
121 yes '' | testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt
-get" purge -y fdleaks -qq
123 testequal '3' grep -c '^STDIN: ' rootdir/var/log/apt/term.log