From 299aea924ccef428219ed6f1a026c122678429e6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 18 Nov 2014 00:59:39 +0100 Subject: fix PTY interaction on linux and kfreebsd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We run dpkg on its own pty, so we can log its output and have our own output around it (like the progress bar), while also allowing debconf and configfile prompts to happen. In commit 223ae57d468fdcac451209a095047a07a5698212 we changed to constantly reopening the slave for kfreebsd. This has the sideeffect though that in some cases slave and master will lose their connection on linux, so that no output is passed along anymore. We fix this by having always an fd referencing the slave open (linux), but we don't use it (kfreebsd). Failing to get our PTY up and running has many (bad) consequences including (not limited to, nor all at ones or in any case) garbled ouput, no output, no logging, a (partial) mixture of the previous items, … This commit is therefore also reshuffling quiet a bit of the creation code to get especially the output part up and running on linux and the logging for kfreebsd. Note that the testcase tries to cover some cases, but this is an interactivity issue so only interactive usage can really be a good test. Closes: 765687 --- .../test-no-fds-leaked-to-maintainer-scripts | 40 ++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'test/integration/test-no-fds-leaked-to-maintainer-scripts') diff --git a/test/integration/test-no-fds-leaked-to-maintainer-scripts b/test/integration/test-no-fds-leaked-to-maintainer-scripts index 6ed120090..3c6457cab 100755 --- a/test/integration/test-no-fds-leaked-to-maintainer-scripts +++ b/test/integration/test-no-fds-leaked-to-maintainer-scripts @@ -8,7 +8,7 @@ setupenvironment configarchitecture 'native' configdpkgnoopchroot -setupsimplenativepackage "fdleaks" 'native' '1.0' 'unstable' +setupsimplenativepackage "fdleaks" 'all' '1.0' 'unstable' BUILDDIR="incoming/fdleaks-1.0" for script in 'preinst' 'postinst' 'prerm' 'postrm'; do echo '#!/bin/sh @@ -19,7 +19,8 @@ rm -rf "$BUILDDIR" setupaptarchive -testsuccess aptget install -y fdleaks +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 @@ -29,7 +30,23 @@ else msgfail fi -testsuccess aptget purge -y fdleaks +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 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 +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 @@ -38,3 +55,20 @@ else 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 +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 +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 ' cut -f 3- -d' ' rootdir/var/log/dpkg.log -- cgit v1.2.3