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-18 02:41:20 +0100
commit0c78757010a17173bdc79b818133697e7dcbf6a4 (patch)
tree666aa7d48511f0f3c8d31a0bf8a3f5f0f06e83d8 /test/integration/test-no-fds-leaked-to-maintainer-scripts
parent4bb006d1ddcf1807474067dcbef9fb0bb5def0ac (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