4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture 'amd64' 'i386'
11 if [ ! -e /proc/self/fd ]; then
12 msgskip "needs
/proc
/self
/fd
"
16 setupsimplenativepackage "fdleaks
" 'all' '1.0' 'unstable'
17 BUILDDIR="incoming
/fdleaks
-1.0
"
18 for script in 'preinst' 'postinst' 'prerm' 'postrm'; do
19 cat > ${BUILDDIR}/debian/$script << EOF
21 if [ -e '$(pwd)/rootdir/tmp/read_stdin' ]; then
23 echo "STDIN
: -\
$line-"
28 buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
32 if dpkg --compare-versions "$(dpkg_version)" 'lt' '1.16.2'; then
38 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
39 testsuccess aptget install -y fdleaks -qq < /dev/null
42 msgtest 'Check if fds were not' "leaked
: expect
$1"
43 if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = "$1" ]; then
47 cat rootdir/tmp/testsuccess.output
54 cp rootdir/tmp/testsuccess.output terminal.output
55 tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
56 testfileequal 'terminal.log' "$(cat terminal.output)"
58 testequal "startup archives unpack
59 install $PKGNAME <none
> 1.0
60 status half
-installed $PKGNAME 1.0
61 status unpacked
$PKGNAME 1.0
62 status unpacked
$PKGNAME 1.0
63 startup packages configure
64 configure
$PKGNAME 1.0 <none
>
65 status unpacked
$PKGNAME 1.0
66 status half
-configured $PKGNAME 1.0
67 status installed
$PKGNAME 1.0" cut -f 3- -d' ' rootdir/var/log/dpkg.log
71 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
72 testsuccess aptget purge -y fdleaks -qq
76 cp rootdir/tmp/testsuccess.output terminal.output
77 tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
78 testfileequal 'terminal.log' "$(cat terminal.output)"
80 if dpkg --compare-versions "$(dpkg_version)" 'ge' '1.18.11'; then
81 testequal "startup packages remove
82 status installed
$PKGNAME 1.0
83 remove
$PKGNAME 1.0 <none
>
84 status half
-configured $PKGNAME 1.0
85 status half
-installed $PKGNAME 1.0
86 status config
-files $PKGNAME 1.0
87 status config
-files $PKGNAME 1.0
88 startup packages configure
89 startup packages purge
90 purge
$PKGNAME 1.0 <none
>
91 status config
-files $PKGNAME 1.0
92 status config
-files $PKGNAME 1.0
93 status config
-files $PKGNAME 1.0
94 status config
-files $PKGNAME 1.0
95 status config
-files $PKGNAME 1.0
96 status not
-installed $PKGNAME <none
>
97 startup packages configure
" cut -f 3- -d' ' rootdir/var/log/dpkg.log
99 testequal "startup packages remove
100 status installed
$PKGNAME 1.0
101 remove
$PKGNAME 1.0 <none
>
102 status half
-configured $PKGNAME 1.0
103 status half
-installed $PKGNAME 1.0
104 status config
-files $PKGNAME 1.0
105 status config
-files $PKGNAME 1.0
106 startup packages configure
107 startup packages purge
108 remove
$PKGNAME 1.0 <none
>
109 purge
$PKGNAME 1.0 <none
>
110 status config
-files $PKGNAME 1.0
111 status config
-files $PKGNAME 1.0
112 status config
-files $PKGNAME 1.0
113 status config
-files $PKGNAME 1.0
114 status config
-files $PKGNAME 1.0
115 status not
-installed $PKGNAME <none
>
116 startup packages configure
" cut -f 3- -d' ' rootdir/var/log/dpkg.log
118 testequalor2 "dpkg
-query: no packages found matching
${PKGNAME}" "No packages found matching
${PKGNAME}.
" dpkg -l "$PKGNAME"
122 msgtest 'setsid provided is new enough to support' '-w'
123 if dpkg-checkbuilddeps -d 'util-linux (>= 2.24.2-1)' /dev/null >/dev/null 2>&1; then
126 msgskip "$(command dpkg -l util-linux)"
130 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
131 testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt
-get" install -y fdleaks -qq < /dev/null
134 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
135 testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt
-get" purge -y fdleaks -qq
138 touch rootdir/tmp/read_stdin
140 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
141 for i in $(seq 1 10); do echo "$i"; done | testsuccess aptget install -y fdleaks -qq
143 testequal '2' grep -c '^STDIN: ' rootdir/var/log/apt/term.log
145 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
146 yes '' | testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt
-get" purge -y fdleaks -qq
148 testequal '3' grep -c '^STDIN: ' rootdir/var/log/apt/term.log