]> git.saurik.com Git - apt.git/commitdiff
check for failure message in testsuccess/failure
authorDavid Kalnischkies <david@kalnischkies.de>
Sun, 19 Oct 2014 12:14:37 +0000 (14:14 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Mon, 20 Oct 2014 08:37:46 +0000 (10:37 +0200)
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

apt-pkg/packagemanager.cc
test/integration/framework
test/integration/test-apt-cli-update
test/integration/test-apt-update-expected-size
test/integration/test-bug-673536-pre-depends-breaks-loop
test/integration/test-bug-733028-gpg-resource-limit
test/integration/test-conflicts-loop
test/integration/test-essential-force-loopbreak
test/integration/test-releasefile-valid-until

index 101912f9d107f55114ac45a91e56c0659861178a..2247d04db1a6c1db7570eba9819f1490813ed86f 100644 (file)
@@ -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)
                     {
                     // 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();
                        _error->DumpErrors(std::clog);
                     }
                     _error->RevertToStack();
index d9851a48cfe065dcab121924f9752e4f6894078c..617daa2836eeb46de895cf8deaf6c8e3880461bc 100644 (file)
@@ -1205,8 +1205,18 @@ testsuccess() {
                msgtest 'Test for successful execution of' "$*"
        fi
        local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
                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
        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"
                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
                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' "$@"
 }
        fi
        aptautotest 'testfailure' "$@"
 }
index 8237bf03f08c14b7c05c5267efa5f12480937ab0..987bb9adb3d7f92ff4b8eb6d56fd0a706388e854 100755 (executable)
@@ -10,7 +10,7 @@ configarchitecture "i386"
 insertpackage 'unstable' 'foo' 'all' '2.0'
 insertinstalledpackage 'foo' 'all' '1.0'
 
 insertpackage 'unstable' 'foo' 'all' '2.0'
 insertinstalledpackage 'foo' 'all' '1.0'
 
-setupaptarchive
+setupaptarchive --no-update
 
 APTARCHIVE=$(readlink -f ./aptarchive)
 
 
 APTARCHIVE=$(readlink -f ./aptarchive)
 
index b71853406ec8b7ff834b5f98630bd70816b354dc..2acf56961c4f26fb7be99000608f744acb91d612 100755 (executable)
@@ -15,16 +15,16 @@ changetowebserver
 # normal update works fine
 testsuccess aptget update
 
 # 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
 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'
 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
     msgpass
 else
-    cat output.log
+    cat rootdir/tmp/testsuccess.output
     msgfail
 fi
 # ensure the failed InRelease file got renamed
     msgfail
 fi
 # ensure the failed InRelease file got renamed
index 21bd5e065798964acc8a562697da5c24e8d0a8a9..eb47553dcd8da71e9a7b27ab9c1f886d14d3e14e 100755 (executable)
@@ -24,12 +24,11 @@ testloopbreak() {
        cp -a dpkg.status.backup rootdir/var/lib/dpkg/status
        rm -f rootdir/var/lib/apt/extended_states
 
        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
 
        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
 }
 
        testdpkginstalled advanced basic common
 }
 
index f9c80496350d046cfa3293ffa3eeef38c5d44bb9..7040856b3760be04738471b17bbe2df21e09b8a6 100755 (executable)
@@ -17,11 +17,11 @@ done
 aptkey list | grep '^pub' > aptkey.list
 testfileequal ./aptkey.list 'pub   2048R/DBAC8DAE 2010-08-18'
 
 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'
 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
        msgfail
-       cat update.log
 else
        msgpass
 fi
 else
        msgpass
 fi
index 0906ef8fa4d4c8db2e7fd5022ceb89c5082445e7..81731dfe4f642f6cab914033bd7cccf907c0851a 100755 (executable)
@@ -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
 
 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
index ac8fc6d2833f264329ae861860c186d969f15775..1493430d85c24175413695e31edebdad83ccabd4 100755 (executable)
@@ -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
 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
        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'
 }
 
        testdpkginstalled 'sysvinit' 'systemd-sysv'
 }
 
index e673d5f716aab9f4a4ad5582c8029ac21c8940b6..0d9a9125476371bc440e662de4497954b0201517 100755 (executable)
@@ -12,84 +12,38 @@ getlabelfromsuite() {
        echo -n 'Testcases'
 }
 
        echo -n 'Testcases'
 }
 
+setupaptarchive --no-update
 
 
-setupaptarchive
-
-setupreleasefile() {
+runtest() {
+       local MSG="$1"
+       msgtest "$1" "$2"
        rm -rf rootdir/var/lib/apt/lists
        aptget clean
        rm -rf rootdir/var/lib/apt/lists
        aptget clean
-       generatereleasefiles "$1" "$2"
+       generatereleasefiles "$3" "$4"
        signreleasefiles
        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
        else
-               return 0
+               testfailure --nomsg aptget update "$@"
+               testsuccess grep -q 'is expired' rootdir/tmp/testfailure.output
        fi
 }
 
        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