]> git.saurik.com Git - apt.git/commitdiff
testcases: do not allow warnings in testsuccess
authorDavid Kalnischkies <david@kalnischkies.de>
Mon, 20 Oct 2014 08:23:41 +0000 (10:23 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Mon, 20 Oct 2014 08:37:46 +0000 (10:37 +0200)
Adds a new testwarning which tests for zero exit and the presents of a
warning in the output, failing if either is not the case or if an error
is found, too. This allows us to change testsuccess to accept only
totally successful executions (= without warnings) which should help
finding regressions.

Git-Dch: Ignore

12 files changed:
test/integration/framework
test/integration/test-apt-by-hash-update
test/integration/test-apt-get-source-authenticated
test/integration/test-apt-update-expected-size
test/integration/test-apt-update-ims
test/integration/test-apt-update-nofallback
test/integration/test-apt-update-rollback
test/integration/test-apt-update-unauth
test/integration/test-bug-596498-trusted-unsigned-repo
test/integration/test-bug-617690-allow-unauthenticated-makes-all-untrusted
test/integration/test-http-pipeline-messup
test/integration/test-sourceslist-trusted-options

index 617daa2836eeb46de895cf8deaf6c8e3880461bc..9ce300d55a56591b943b6cfd63ade4b24ac78072 100644 (file)
@@ -1205,12 +1205,43 @@ testsuccess() {
                msgtest 'Test for successful execution of' "$*"
        fi
        local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
+       if "$@" >${OUTPUT} 2>&1; then
+               if expr match "$1" '^apt.*' >/dev/null; then
+                       if grep -q -E '^[WE]: ' "$OUTPUT"; then
+                               echo >&2
+                               cat >&2 $OUTPUT
+                               msgfail 'successful run, but output contains warnings/errors'
+                       else
+                               msgpass
+                       fi
+               else
+                       msgpass
+               fi
+       else
+               local EXITCODE=$?
+               echo >&2
+               cat >&2 $OUTPUT
+               msgfail "exitcode $EXITCODE"
+       fi
+       aptautotest 'testsuccess' "$@"
+}
+testwarning() {
+       if [ "$1" = '--nomsg' ]; then
+               shift
+       else
+               msgtest 'Test for successful execution with warnings of' "$*"
+       fi
+       local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
        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'
+                       elif ! grep -q -E '^W: ' "$OUTPUT"; then
+                               echo >&2
+                               cat >&2 $OUTPUT
+                               msgfail 'successful run, but output contains no warnings'
                        else
                                msgpass
                        fi
@@ -1223,9 +1254,8 @@ testsuccess() {
                cat >&2 $OUTPUT
                msgfail "exitcode $EXITCODE"
        fi
-       aptautotest 'testsuccess' "$@"
+       aptautotest 'testwarning' "$@"
 }
-
 testfailure() {
        if [ "$1" = '--nomsg' ]; then
                shift
index 6e1ecdaff21aaae863c78e0a9926d2e86adf65f4..d9d0b146ff2d930bc79f6f99ce1fee9943829e3b 100755 (executable)
@@ -34,7 +34,7 @@ Building dependency tree...
 E: Unable to locate package foo" aptget install -q -s foo
 
 # ensure we can apt-get update by hash
-testsuccess aptget update -o APT::Acquire::By-Hash=1 
+testsuccess aptget update -o APT::Acquire::By-Hash=1 -o Acquire::Languages=none
 
 # ensure it works
 testequal "Inst foo (1.0 unstable [all])
@@ -45,5 +45,5 @@ MAGIC="Acquire-By-Hash: true"
 sed -i "s#Suite: unstable#Suite: unstable\n$MAGIC#" aptarchive/dists/unstable/Release
 signreleasefiles
 # ... and verify that it fetches by hash now
-testsuccess aptget update
+testsuccess aptget update -o Acquire::Languages=none
 
index d833ddd8533e9fe8037f86c2789f5bad924462f2..fedfc83086a5a4154a2d619e27bdb417847e3c48 100755 (executable)
@@ -21,7 +21,7 @@ APTARCHIVE=$(readlink -f ./aptarchive)
 rm -f $APTARCHIVE/dists/unstable/*Release*
 
 # update without authenticated InRelease file
-testsuccess aptget update --allow-insecure-repositories
+testwarning aptget update --allow-insecure-repositories
 
 # this all should fail
 testfailure aptget install -y foo
index 2acf56961c4f26fb7be99000608f744acb91d612..045217a7704fd1052edd61b2c9a2ca925c5446ce 100755 (executable)
@@ -42,4 +42,3 @@ rm -f rootdir/var/lib/apt/lists/localhost*
 testequal "W: Failed to fetch http://localhost:8080/dists/unstable/main/binary-i386/Packages  Writing more data than expected ($NEW_SIZE > $SIZE)
 
 E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq
-
index eece0c84c6c5f9bbe78809a57309e236ee374cb2..afae9956385bd909ae689168b126bc65c6ef06ad 100755 (executable)
@@ -12,9 +12,15 @@ setupaptarchive --no-update
 changetowebserver
 
 runtest() {
+    configallowinsecurerepositories "${1:-false}"
+
     rm -f rootdir/var/lib/apt/lists/localhost*
 
-    testsuccess aptget update
+    if [ "$1" = 'true' ]; then
+       testwarning aptget update
+    else
+       testsuccess aptget update
+    fi
 
     # ensure no leftovers in partial
     testfailure ls "rootdir/var/lib/apt/lists/partial/*"
@@ -62,10 +68,7 @@ runtest
 echo "Acquire::GzipIndexes "1";" > rootdir/etc/apt/apt.conf.d/02compressindex
 runtest
 
-
 # no Release.gpg or InRelease
-configallowinsecurerepositories "true"
-
 msgmsg "Release only"
 EXPECT="Ign http://localhost:8080 unstable InRelease
   404  Not Found
@@ -81,7 +84,7 @@ W: The data from 'http://localhost:8080 unstable Release.gpg' is not signed. Pac
 find aptarchive -name 'Release.gpg' -delete
 
 echo "Acquire::GzipIndexes "0";" > rootdir/etc/apt/apt.conf.d/02compressindex
-runtest
+runtest "true"
 
 echo "Acquire::GzipIndexes "1";" > rootdir/etc/apt/apt.conf.d/02compressindex
-runtest
+runtest "true"
index 12977129fba4f2a0e30445b703350f9ea1e9045c..831fc67eb1c5c96082a3a5a4d2986191d537195b 100755 (executable)
@@ -54,8 +54,7 @@ assert_repo_is_intact()
 setupaptarchive_with_lists_clean()
 {
     setupaptarchive --no-update
-    rm -f rootdir/var/lib/apt/lists/_*
-    #rm -rf rootdir/var/lib/apt/lists
+    rm -rf rootdir/var/lib/apt/lists
 }
 
 test_from_inrelease_to_unsigned()
@@ -87,14 +86,15 @@ test_from_inrelease_to_unsigned_with_override()
 {
     # setup archive with InRelease file
     setupaptarchive_with_lists_clean
-    testsuccess aptget update
+    # FIXME: is not what the server reported 4104 4106
+    testsuccess aptget update #-o Debug::pkgAcquire::Worker=1
 
     # simulate moving to a unsigned but otherwise valid repo
     simulate_mitm_and_inject_evil_package
     generatereleasefiles
 
     # and ensure we can update to it (with enough force) 
-    testsuccess aptget update --allow-insecure-repositories \
+    testwarning aptget update --allow-insecure-repositories \
         -o Acquire::AllowDowngradeToInsecureRepositories=1
     # but that the individual packages are still considered untrusted
     testequal "WARNING: The following packages cannot be authenticated!
index d33411da46ed241e87519df7ddd4947fa29a8245..9efc194a0c68e294d54a265ec9a7f30c9ce7944f 100755 (executable)
@@ -117,7 +117,7 @@ test_unauthenticated_to_invalid_inrelease() {
     rm $APTARCHIVE/dists/unstable/InRelease
     rm $APTARCHIVE/dists/unstable/Release.gpg
 
-    testsuccess aptget update --allow-insecure-repositories
+    testwarning aptget update --allow-insecure-repositories
     listcurrentlistsdirectory > lists.before
     testequal "WARNING: The following packages cannot be authenticated!
   old
index 1b5dbc6c465308008503887b80d98d739acba5d5..7347f7d10ebb3eb82a7aa87fbf6ad5f976a72579 100755 (executable)
@@ -27,7 +27,7 @@ runtest() {
     rm -rf rootdir/var/lib/apt/lists/
     find aptarchive/ -name '*Release*' -delete
 
-    testsuccess aptget update --allow-insecure-repositories
+    testwarning aptget update --allow-insecure-repositories
 
     # become authenticated
     generatereleasefiles
index a08c153f82ebd80fe30617143f772dd87a137d5d..1e5e75b0e836291de2c1cb901fa708abcdd3a45e 100755 (executable)
@@ -12,7 +12,7 @@ setupaptarchive
 
 aptgetupdate() {
        rm -rf rootdir/var/lib/apt/ rootdir/var/cache/apt/*.bin
-       testsuccess aptget update --allow-insecure-repositories
+       ${1:-testwarning} aptget update --allow-insecure-repositories
 }
 
 PKGTEXT="$(aptget install cool --assume-no -d | head -n 7)"
@@ -25,7 +25,7 @@ testequal "$PKGTEXT
 Download complete and in download only mode" aptget install cool --assume-no -d --allow-unauthenticated
 
 sed -i -e 's#deb#deb [trusted=no]#' $DEBFILE
-aptgetupdate
+aptgetupdate 'testsuccess'
 
 testequal "$PKGTEXT
 WARNING: The following packages cannot be authenticated!
index 0736bb6dc598de4f07084f011edc0c83efc9ab93..164dca070bb84e5670dc4c8291cfd8837a5aa9d0 100755 (executable)
@@ -34,7 +34,7 @@ testrun() {
                testsuccess aptget download cool --allow-unauthenticated
                testfileexists 'cool_1.0_i386.deb'
        else
-                testsuccess aptget update --allow-insecure-repositories
+                testwarning aptget update --allow-insecure-repositories
 
                testfailure aptget download cool
                testfilemissing 'cool_1.0_i386.deb'
index 405574e8ae297c59e3d82469737aff870b79672e..dda8ef7eb1737e03b085ee71e7ed8c40d405395d 100755 (executable)
@@ -35,7 +35,7 @@ testfailure test -f pkga_1.0_all.deb
 echo 'Acquire::http::Pipeline-Depth 10;' > rootdir/etc/apt/apt.conf.d/99enable-pipeline
 
 # the output is a bit strange: it looks like it has downloaded pkga 4 times
-testsuccess aptget download pkga pkgb pkgc pkgd
+testwarning aptget download pkga pkgb pkgc pkgd
 for pkg in 'pkga' 'pkgb' 'pkgc' 'pkgd'; do
        testsuccess test -f ${pkg}_1.0_all.deb
        testsuccess cmp incoming/${pkg}_1.0_all.deb ${pkg}_1.0_all.deb
index c954f2f4f0aa1be977e25d88e638412345e63ca0..28415dd6228e81f408113f62e2b742123f3aa38d 100755 (executable)
@@ -57,14 +57,14 @@ aptgetupdate() {
        # note that insecure with trusted=yes are allowed
        # as the trusted=yes indicates that security is provided by
        # something above the understanding of apt
-       testsuccess aptget update --no-allow-insecure-repositories
+       ${1:-testsuccess} aptget update --no-allow-insecure-repositories
 }
 
 insecureaptgetupdate() {
        rm -rf rootdir/var/lib/apt/lists
        testfailure aptget update --no-allow-insecure-repositories
        rm -rf rootdir/var/lib/apt/lists
-       testsuccess aptget update --allow-insecure-repositories
+       testwarning aptget update --allow-insecure-repositories
 }
 
 msgmsg 'Test without trusted option and good sources'
@@ -103,7 +103,7 @@ everythingsucceeds -t testing
 msgmsg 'Test with trusted=yes option and good and unsigned sources'
 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
-aptgetupdate
+aptgetupdate 'testwarning'
 everythingsucceeds
 everythingsucceeds -t stable
 everythingsucceeds -t testing
@@ -128,7 +128,7 @@ everythingsucceeds -t testing
 msgmsg 'Test with trusted=yes option and good and unknown sources'
 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
-aptgetupdate
+aptgetupdate 'testwarning'
 everythingsucceeds
 everythingsucceeds -t stable
 everythingsucceeds -t testing
@@ -154,7 +154,7 @@ everythingsucceeds -t testing
 msgmsg 'Test with trusted=yes option and good and expired sources'
 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
-aptgetupdate
+aptgetupdate 'testwarning'
 everythingsucceeds
 everythingsucceeds -t stable
 everythingsucceeds -t testing
@@ -181,7 +181,7 @@ everythingfails -t testing
 msgmsg 'Test with trusted=yes option and unsigned and good sources'
 cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
 sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
-aptgetupdate
+aptgetupdate 'testwarning'
 everythingsucceeds
 everythingsucceeds -t stable
 everythingsucceeds -t testing