summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-10-19 14:14:37 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2014-10-20 10:37:46 +0200
commit1df24acfdb8ba1cd8bbbaa166f170dda480ce41e (patch)
tree992b2cc2f5f02a34a49b5bac160070ec30cf34b1 /test
parentcecc5532b8d64394a8f8641e78f4a0cc5f7a51fc (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework29
-rwxr-xr-xtest/integration/test-apt-cli-update2
-rwxr-xr-xtest/integration/test-apt-update-expected-size8
-rwxr-xr-xtest/integration/test-bug-673536-pre-depends-breaks-loop5
-rwxr-xr-xtest/integration/test-bug-733028-gpg-resource-limit6
-rwxr-xr-xtest/integration/test-conflicts-loop2
-rwxr-xr-xtest/integration/test-essential-force-loopbreak4
-rwxr-xr-xtest/integration/test-releasefile-valid-until100
8 files changed, 65 insertions, 91 deletions
diff --git a/test/integration/framework b/test/integration/framework
index d9851a48c..617daa283 100644
--- a/test/integration/framework
+++ b/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' "$@"
}
diff --git a/test/integration/test-apt-cli-update b/test/integration/test-apt-cli-update
index 8237bf03f..987bb9adb 100755
--- a/test/integration/test-apt-cli-update
+++ b/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)
diff --git a/test/integration/test-apt-update-expected-size b/test/integration/test-apt-update-expected-size
index b71853406..2acf56961 100755
--- a/test/integration/test-apt-update-expected-size
+++ b/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
diff --git a/test/integration/test-bug-673536-pre-depends-breaks-loop b/test/integration/test-bug-673536-pre-depends-breaks-loop
index 21bd5e065..eb47553dc 100755
--- a/test/integration/test-bug-673536-pre-depends-breaks-loop
+++ b/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
}
diff --git a/test/integration/test-bug-733028-gpg-resource-limit b/test/integration/test-bug-733028-gpg-resource-limit
index f9c804963..7040856b3 100755
--- a/test/integration/test-bug-733028-gpg-resource-limit
+++ b/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
diff --git a/test/integration/test-conflicts-loop b/test/integration/test-conflicts-loop
index 0906ef8fa..81731dfe4 100755
--- a/test/integration/test-conflicts-loop
+++ b/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
diff --git a/test/integration/test-essential-force-loopbreak b/test/integration/test-essential-force-loopbreak
index ac8fc6d28..1493430d8 100755
--- a/test/integration/test-essential-force-loopbreak
+++ b/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'
}
diff --git a/test/integration/test-releasefile-valid-until b/test/integration/test-releasefile-valid-until
index e673d5f71..0d9a91254 100755
--- a/test/integration/test-releasefile-valid-until
+++ b/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