summaryrefslogtreecommitdiff
path: root/test/integration/test-no-fds-leaked-to-maintainer-scripts
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-11-17 15:06:35 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-11-28 16:15:39 +0100
commit9fc0b435593839de47098212f0ae5f15b6263099 (patch)
tree43add4893ac6f18093d4b1c6c796934816f489d7 /test/integration/test-no-fds-leaked-to-maintainer-scripts
parent2901c54193d013d618158bee821ed2108bb12c7f (diff)
close leaking slave fd after setting up pty magic
The fd moves out of scope here anyway, so we should close it properly instead of leaking it which will tickle down to dpkg maintainer scripts. Closes: 767774
Diffstat (limited to 'test/integration/test-no-fds-leaked-to-maintainer-scripts')
-rwxr-xr-xtest/integration/test-no-fds-leaked-to-maintainer-scripts40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/integration/test-no-fds-leaked-to-maintainer-scripts b/test/integration/test-no-fds-leaked-to-maintainer-scripts
new file mode 100755
index 000000000..6ed120090
--- /dev/null
+++ b/test/integration/test-no-fds-leaked-to-maintainer-scripts
@@ -0,0 +1,40 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'native'
+configdpkgnoopchroot
+
+setupsimplenativepackage "fdleaks" 'native' '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
+
+testsuccess aptget install -y fdleaks
+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
+
+testsuccess aptget purge -y fdleaks
+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