Просмотр исходного кода

check for failure message in testsuccess/failure

These functions check the exit code of the command, but for apt commands
we can go further and require an error message for non-zero exits and
none for zero exits.

Git-Dch: Ignore
David Kalnischkies лет назад: 11
Родитель
Сommit
1df24acfdb

+ 1 - 1
apt-pkg/packagemanager.cc

@@ -843,7 +843,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
 		     // but if it fails ignore this failure and look for alternative ways of solving
 		     if (Debug)
 		     {
-			clog << OutputInDepth(Depth) << "Avoidance unpack of " << ConflictPkg.FullName() << " failed for " << End << std::endl;
+			clog << OutputInDepth(Depth) << "Avoidance unpack of " << ConflictPkg.FullName() << " failed for " << End << " ignoring:" << std::endl;
 			_error->DumpErrors(std::clog);
 		     }
 		     _error->RevertToStack();

+ 25 - 4
test/integration/framework

@@ -1205,8 +1205,18 @@ testsuccess() {
 		msgtest 'Test for successful execution of' "$*"
 	fi
 	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
-	if $@ >${OUTPUT} 2>&1; then
-		msgpass
+	if "$@" >${OUTPUT} 2>&1; then
+		if expr match "$1" '^apt.*' >/dev/null; then
+			if grep -q -E '^E: ' "$OUTPUT"; then
+				echo >&2
+				cat >&2 $OUTPUT
+				msgfail 'successful run, but output contains errors'
+			else
+				msgpass
+			fi
+		else
+			msgpass
+		fi
 	else
 		local EXITCODE=$?
 		echo >&2
@@ -1223,13 +1233,24 @@ testfailure() {
 		msgtest 'Test for failure in execution of' "$*"
 	fi
 	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
-	if $@ >${OUTPUT} 2>&1; then
+	if "$@" >${OUTPUT} 2>&1; then
 		local EXITCODE=$?
 		echo >&2
 		cat >&2 $OUTPUT
 		msgfail "exitcode $EXITCODE"
 	else
-		msgpass
+		local EXITCODE=$?
+		if expr match "$1" '^apt.*' >/dev/null; then
+			if ! grep -q -E '^E: ' "$OUTPUT"; then
+				echo >&2
+				cat >&2 $OUTPUT
+				msgfail "run failed with exitcode ${EXITCODE}, but with no errors"
+			else
+				msgpass
+			fi
+		else
+			msgpass
+		fi
 	fi
 	aptautotest 'testfailure' "$@"
 }

+ 1 - 1
test/integration/test-apt-cli-update

@@ -10,7 +10,7 @@ configarchitecture "i386"
 insertpackage 'unstable' 'foo' 'all' '2.0'
 insertinstalledpackage 'foo' 'all' '1.0'
 
-setupaptarchive
+setupaptarchive --no-update
 
 APTARCHIVE=$(readlink -f ./aptarchive)
 

+ 4 - 4
test/integration/test-apt-update-expected-size

@@ -15,16 +15,16 @@ changetowebserver
 # normal update works fine
 testsuccess aptget update
 
-# make InRelease really big
+# make InRelease really big to trigger fallback
 mv aptarchive/dists/unstable/InRelease aptarchive/dists/unstable/InRelease.good
 dd if=/dev/zero of=aptarchive/dists/unstable/InRelease bs=1M count=2 2>/dev/null
 touch -d '+1hour' aptarchive/dists/unstable/InRelease
-aptget update -o Apt::Get::List-Cleanup=0  -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0 > output.log
+testsuccess aptget update -o Apt::Get::List-Cleanup=0  -o acquire::MaxReleaseFileSize=$((1*1000*1000)) -o Debug::pkgAcquire::worker=0
 msgtest 'Check that the max write warning is triggered'
-if grep -q "Writing more data than expected" output.log; then
+if grep -q "Writing more data than expected" rootdir/tmp/testsuccess.output; then
     msgpass
 else
-    cat output.log
+    cat rootdir/tmp/testsuccess.output
     msgfail
 fi
 # ensure the failed InRelease file got renamed

+ 2 - 3
test/integration/test-bug-673536-pre-depends-breaks-loop

@@ -24,12 +24,11 @@ testloopbreak() {
 	cp -a dpkg.status.backup rootdir/var/lib/dpkg/status
 	rm -f rootdir/var/lib/apt/extended_states
 
-
-	testsuccess aptget install advanced=1 -y -t "$1" -o Debug::pkgPackageManager=1
+	testsuccess aptget install advanced=1 -y -t "$1"
 	testdpkginstalled advanced
 	testdpkgnotinstalled basic common
 
-	testsuccess aptget dist-upgrade -y -t "$1" -o Debug::pkgPackageManager=1
+	testsuccess aptget dist-upgrade -y -t "$1"
 	testdpkginstalled advanced basic common
 }
 

+ 3 - 3
test/integration/test-bug-733028-gpg-resource-limit

@@ -17,11 +17,11 @@ done
 aptkey list | grep '^pub' > aptkey.list
 testfileequal ./aptkey.list 'pub   2048R/DBAC8DAE 2010-08-18'
 
+testsuccess aptget update
 msgtest 'Test for no gpg errors/warnings in' 'apt-get update'
-aptget update > update.log 2>&1
-if grep -iq 'GPG' update.log; then
+if grep -iq 'GPG' rootdir/tmp/testsuccess.output; then
+	cat rootdir/tmp/testsuccess.output
 	msgfail
-	cat update.log
 else
 	msgpass
 fi

+ 1 - 1
test/integration/test-conflicts-loop

@@ -30,4 +30,4 @@ Conf openjdk-6-jre (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386])
 Inst openjdk-6-jre-headless [6b16-1.8-0ubuntu1] (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386])
 Conf openjdk-6-jre-headless (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386])' aptget dist-upgrade -s -o APT::Immediate-Configure-All=true
 
-testsuccess aptget dist-upgrade -s -o Debug::pkgPackageManager=1
+testsuccess aptget dist-upgrade -s

+ 2 - 2
test/integration/test-essential-force-loopbreak

@@ -37,13 +37,13 @@ The following packages will be upgraded:
 E: This installation run will require temporarily removing the essential package sysvinit:$(getarchitecture 'native') due to a Conflicts/Pre-Depends loop. This is often bad, but if you really want to do it, activate the APT::Force-LoopBreak option.
 E: Internal Error, Could not early remove sysvinit:$(dpkg --print-architecture) (2)" aptget install systemd-sysv -t "$1" -s
 	# ensure that really nothing happens
-	testfailure aptget install systemd-sysv -y -t "$1" -o Debug::pkgPackageManager=1
+	testfailure aptget install systemd-sysv -y -t "$1"
 	testdpkginstalled 'sysvinit'
 	testdpkgnotinstalled 'systemd-sysv'
 
 	# with enough force however …
 	cp -a dpkg.status.backup rootdir/var/lib/dpkg/status
-	testsuccess aptget install systemd-sysv -y -t "$1" -o Debug::pkgPackageManager=1 -o APT::Force-LoopBreak=1
+	testsuccess aptget install systemd-sysv -y -t "$1" -o APT::Force-LoopBreak=1
 	testdpkginstalled 'sysvinit' 'systemd-sysv'
 }
 

+ 27 - 73
test/integration/test-releasefile-valid-until

@@ -12,84 +12,38 @@ getlabelfromsuite() {
 	echo -n 'Testcases'
 }
 
+setupaptarchive --no-update
 
-setupaptarchive
-
-setupreleasefile() {
+runtest() {
+	local MSG="$1"
+	msgtest "$1" "$2"
 	rm -rf rootdir/var/lib/apt/lists
 	aptget clean
-	generatereleasefiles "$1" "$2"
+	generatereleasefiles "$3" "$4"
 	signreleasefiles
-}
-
-aptgetupdate() {
-	if aptget update $* 2>&1 | grep -q 'is expired'; then
-		return 1
+	shift 4
+	if expr match "$MSG" '.*accepted.*' >/dev/null; then
+		testsuccess --nomsg aptget update "$@"
+		testfailure grep -q 'is expired' rootdir/tmp/testsuccess.output
 	else
-		return 0
+		testfailure --nomsg aptget update "$@"
+		testsuccess grep -q 'is expired' rootdir/tmp/testfailure.output
 	fi
 }
 
-setupreleasefile
-msgtest 'Release file is accepted as it has' 'no Until'
-testsuccess --nomsg aptgetupdate
-
-setupreleasefile
-msgtest 'Release file is accepted as it has' 'no Until and good Max-Valid'
-testsuccess --nomsg aptgetupdate -o Acquire::Max-ValidTime=3600
-
-setupreleasefile 'now - 2 days'
-msgtest 'Release file is rejected as it has' 'no Until, but bad Max-Valid'
-testfailure --nomsg aptgetupdate -o Acquire::Max-ValidTime=3600
-
-setupreleasefile 'now - 3 days' 'now + 1 day'
-msgtest 'Release file is accepted as it has' 'good Until'
-testsuccess --nomsg aptgetupdate
-
-setupreleasefile 'now - 7 days' 'now - 4 days'
-msgtest 'Release file is rejected as it has' 'bad Until'
-testfailure --nomsg aptgetupdate
-
-setupreleasefile 'now - 7 days' 'now - 4 days'
-msgtest 'Release file is rejected as it has' 'bad Until (ignore good Max-Valid)'
-testfailure --nomsg aptgetupdate -o Acquire::Max-ValidTime=1209600
-
-setupreleasefile 'now - 7 days' 'now - 4 days'
-msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until)'
-testfailure --nomsg aptgetupdate -o Acquire::Max-ValidTime=86400
-
-setupreleasefile 'now - 7 days' 'now + 4 days'
-msgtest 'Release file is rejected as it has' 'bad Max-Valid (good Until)'
-testfailure --nomsg aptgetupdate -o Acquire::Max-ValidTime=86400
-
-setupreleasefile 'now - 7 days' 'now + 4 days'
-msgtest 'Release file is accepted as it has' 'good labeled Max-Valid'
-testsuccess --nomsg aptgetupdate -o Acquire::Max-ValidTime=86400 -o Acquire::Max-ValidTime::Testcases=1209600
-
-setupreleasefile 'now - 7 days' 'now + 4 days'
-msgtest 'Release file is rejected as it has' 'bad labeled Max-Valid'
-testfailure --nomsg aptgetupdate -o Acquire::Max-ValidTime=1209600 -o Acquire::Max-ValidTime::Testcases=86400
-
-setupreleasefile 'now - 7 days' 'now + 1 days'
-msgtest 'Release file is accepted as it has' 'good Until (good Min-Valid, no Max-Valid)'
-testsuccess --nomsg aptgetupdate -o Acquire::Min-ValidTime=1209600
-
-setupreleasefile 'now - 7 days' 'now - 4 days'
-msgtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, no Max-Valid)'
-testsuccess --nomsg aptgetupdate -o Acquire::Min-ValidTime=1209600
-
-setupreleasefile 'now - 7 days' 'now - 2 days'
-msgtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, good Max-Valid) <'
-testsuccess --nomsg aptgetupdate -o Acquire::Min-ValidTime=1209600 -o Acquire::Max-ValidTime=2419200
-
-setupreleasefile 'now - 7 days' 'now - 2 days'
-msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, good Min-Valid) >'
-testfailure --nomsg aptgetupdate -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=2419200
-
-setupreleasefile 'now - 7 days' 'now - 2 days'
-msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) <'
-testfailure --nomsg aptgetupdate -o Acquire::Min-ValidTime=12096 -o Acquire::Max-ValidTime=241920
-
-setupreleasefile 'now - 7 days' 'now - 2 days'
-msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) >'
-testfailure --nomsg aptgetupdate -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=241920
+runtest 'Release file is accepted as it has' 'no Until' '' ''
+runtest 'Release file is accepted as it has' 'no Until and good Max-Valid' '' '' -o Acquire::Max-ValidTime=3600
+runtest 'Release file is rejected as it has' 'no Until, but bad Max-Valid' 'now - 2 days' '' -o Acquire::Max-ValidTime=3600
+runtest 'Release file is accepted as it has' 'good Until' 'now - 3 days' 'now + 1 day'
+runtest 'Release file is rejected as it has' 'bad Until' 'now - 7 days' 'now - 4 days'
+runtest 'Release file is rejected as it has' 'bad Until (ignore good Max-Valid)' 'now - 7 days' 'now - 4 days' -o Acquire::Max-ValidTime=1209600
+runtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until)' 'now - 7 days' 'now - 4 days' -o Acquire::Max-ValidTime=86400
+runtest 'Release file is rejected as it has' 'bad Max-Valid (good Until)' 'now - 7 days' 'now + 4 days' -o Acquire::Max-ValidTime=86400
+runtest 'Release file is accepted as it has' 'good labeled Max-Valid' 'now - 7 days' 'now + 4 days' -o Acquire::Max-ValidTime=86400 -o Acquire::Max-ValidTime::Testcases=1209600
+runtest 'Release file is rejected as it has' 'bad labeled Max-Valid' 'now - 7 days' 'now + 4 days' -o Acquire::Max-ValidTime=1209600 -o Acquire::Max-ValidTime::Testcases=86400
+runtest 'Release file is accepted as it has' 'good Until (good Min-Valid, no Max-Valid)' 'now - 7 days' 'now + 1 days' -o Acquire::Min-ValidTime=1209600
+runtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, no Max-Valid)' 'now - 7 days' 'now - 4 days' -o Acquire::Min-ValidTime=1209600
+runtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, good Max-Valid) <' 'now - 7 days' 'now - 2 days' -o Acquire::Min-ValidTime=1209600 -o Acquire::Max-ValidTime=2419200
+runtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, good Min-Valid) >' 'now - 7 days' 'now - 2 days' -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=2419200
+runtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) <' 'now - 7 days' 'now - 2 days' -o Acquire::Min-ValidTime=12096 -o Acquire::Max-ValidTime=241920
+runtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) >' 'now - 7 days' 'now - 2 days' -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=241920