summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/integration/framework72
-rwxr-xr-xtest/integration/run-tests6
-rwxr-xr-xtest/integration/test-apt-get-clean10
-rwxr-xr-xtest/integration/test-apt-key14
-rwxr-xr-xtest/integration/test-authentication-basic2
-rwxr-xr-xtest/integration/test-bug-738785-switch-protocol2
6 files changed, 64 insertions, 42 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 190d4d665..153c5bb25 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -77,12 +77,6 @@ if [ $MSGLEVEL -le 2 ]; then
msgnmsg() { true; }
msgtest() { true; }
msgpass() { printf " ${CPASS}P${CNORMAL}"; }
- msgskip() { printf " ${CWARNING}S${CNORMAL}" >&2; }
- if [ -n "$CFAIL" ]; then
- msgfail() { printf " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
- else
- msgfail() { printf " ###FAILED###" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
- fi
fi
if [ $MSGLEVEL -le 3 ]; then
msginfo() { true; }
@@ -1228,6 +1222,36 @@ testmarkedauto() {
aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
}
+msgfailoutput() {
+ local MSG="$1"
+ local OUTPUT="$2"
+ shift 2
+ echo >&2
+ if [ "$1" = 'grep' ]; then
+ while [ -n "$2" ]; do shift; done
+ echo "#### Complete file: $1 ####"
+ cat >&2 "$1" || true
+ echo '#### grep output ####'
+ elif [ "$1" = 'test' ]; then
+ # doesn't support ! or non-file flags
+ msgfailoutputstatfile() {
+ local FILEFLAGS='^-[bcdefgGhkLOprsStuwx]$'
+ if expr match "$1" "$FILEFLAGS" >/dev/null; then
+ echo "#### stat(2) of file: $2 ####"
+ stat "$2" || true
+ fi
+ }
+ msgfailoutputstatfile "$2" "$3"
+ while [ -n "$5" ] && [ "$4" = '-o' -o "$4" = '-a' ]; do
+ shift 3
+ msgfailoutputstatfile "$2" "$3"
+ done
+ echo '#### test output ####'
+ fi
+ cat >&2 $OUTPUT
+ msgfail "$MSG"
+}
+
testsuccess() {
if [ "$1" = '--nomsg' ]; then
shift
@@ -1237,10 +1261,10 @@ testsuccess() {
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'
+ if grep -q -E ' runtime error: ' "$OUTPUT"; then
+ msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@"
+ elif grep -q -E '^[WE]: ' "$OUTPUT"; then
+ msgfailoutput 'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
else
msgpass
fi
@@ -1249,9 +1273,7 @@ testsuccess() {
fi
else
local EXITCODE=$?
- echo >&2
- cat >&2 $OUTPUT
- msgfail "exitcode $EXITCODE"
+ msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@"
fi
aptautotest 'testsuccess' "$@"
}
@@ -1264,14 +1286,12 @@ testwarning() {
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'
+ if grep -q -E ' runtime error: ' "$OUTPUT"; then
+ msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@"
+ elif grep -q -E '^E: ' "$OUTPUT"; then
+ msgfailoutput 'successful run, but output contains errors' "$OUTPUT" "$@"
elif ! grep -q -E '^W: ' "$OUTPUT"; then
- echo >&2
- cat >&2 $OUTPUT
- msgfail 'successful run, but output contains no warnings'
+ msgfailoutput 'successful run, but output contains no warnings' "$OUTPUT" "$@"
else
msgpass
fi
@@ -1295,16 +1315,14 @@ testfailure() {
local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
if "$@" >${OUTPUT} 2>&1; then
local EXITCODE=$?
- echo >&2
- cat >&2 $OUTPUT
- msgfail "exitcode $EXITCODE"
+ msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@"
else
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"
+ if grep -q -E ' runtime error: ' "$OUTPUT"; then
+ msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@"
+ elif ! grep -q -E '^E: ' "$OUTPUT"; then
+ msgfailoutput "run failed with exitcode ${EXITCODE}, but with no errors" "$OUTPUT" "$@"
else
msgpass
fi
diff --git a/test/integration/run-tests b/test/integration/run-tests
index c39a2ac68..6c6a37611 100755
--- a/test/integration/run-tests
+++ b/test/integration/run-tests
@@ -46,7 +46,11 @@ for testcase in $(run-parts --list $DIR | grep '/test-'); do
if ! ${testcase}; then
FAIL=$((FAIL+1))
FAILED_TESTS="$FAILED_TESTS $(basename $testcase)"
- echo >&2 "$(basename $testcase) ... FAIL"
+ if [ "$MSGLEVEL" -le 2 ]; then
+ printf >&2 "\n${CHIGH}Running $(basename $testcase) -> FAILED${CRESET}"
+ else
+ echo >&2 "${CHIGH}Running $(basename $testcase) -> FAILED${CRESET}"
+ fi
else
PASS=$((PASS+1))
fi
diff --git a/test/integration/test-apt-get-clean b/test/integration/test-apt-get-clean
index 98f7c84d0..457bff9d3 100755
--- a/test/integration/test-apt-get-clean
+++ b/test/integration/test-apt-get-clean
@@ -26,10 +26,10 @@ touch rootdir/var/cache/apt/archives/foo_4_all.deb
testsuccess aptget clean
-testsuccess test ! -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
-testsuccess test ! -e rootdir/var/cache/apt/archives/foo_1_all.deb
-testsuccess test ! -e rootdir/var/cache/apt/archives/foo_2_all.deb
-testsuccess test ! -e rootdir/var/cache/apt/archives/foo_3_all.deb
-testsuccess test ! -e rootdir/var/cache/apt/archives/foo_4_all.deb
+testfailure test -e rootdir/var/lib/apt/lists/partial/http.debian.net_debian_dists_sid_main_i18n_Translation-en
+testfailure test -e rootdir/var/cache/apt/archives/foo_1_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_2_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_3_all.deb
+testfailure test -e rootdir/var/cache/apt/archives/foo_4_all.deb
diff --git a/test/integration/test-apt-key b/test/integration/test-apt-key
index e6ac530a6..b6b7b7909 100755
--- a/test/integration/test-apt-key
+++ b/test/integration/test-apt-key
@@ -41,7 +41,7 @@ gpg: unchanged: 1' aptkey --fakeroot update
testaptkeys 'pub 2048R/DBAC8DAE 2010-08-18'
- testsuccess test ! -e rootdir/etc/apt/trusted.gpg
+ testfailure test -e rootdir/etc/apt/trusted.gpg
testsuccess aptkey --fakeroot add ./keys/rexexpired.pub
msgtest 'Check if trusted.gpg is created with permissions set to' '0644'
if [ "$(stat -c '%a' rootdir/etc/apt/trusted.gpg )" = '644' ]; then
@@ -78,7 +78,7 @@ pub 2048R/DBAC8DAE 2010-08-18'
cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
testempty aptkey list
- testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+ testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
msgtest 'Test key removal with' 'long key ID'
@@ -86,7 +86,7 @@ pub 2048R/DBAC8DAE 2010-08-18'
cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess --nomsg aptkey --fakeroot del 5A90D141DBAC8DAE
testempty aptkey list
- testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+ testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
msgtest 'Test key removal with' 'fingerprint'
@@ -94,7 +94,7 @@ pub 2048R/DBAC8DAE 2010-08-18'
cp -a keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess --nomsg aptkey --fakeroot del 34A8E9D18DB320F367E8EAA05A90D141DBAC8DAE
testempty aptkey list
- testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+ testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
msgtest 'Test key removal with' 'single key in softlink'
@@ -102,7 +102,7 @@ pub 2048R/DBAC8DAE 2010-08-18'
ln -s $(readlink -f ./keys/joesixpack.pub) rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
testempty aptkey list
- testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+ testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess test -L rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
cleanplate
@@ -125,7 +125,7 @@ pub 2048R/528144E2 2011-01-16'
testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
testaptkeys 'pub 2048R/528144E2 2011-01-16'
testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
- testsuccess test ! -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg
+ testfailure test -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg
testsuccess test -L rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
msgtest 'Test key removal with' 'multiple files including key'
@@ -134,7 +134,7 @@ pub 2048R/528144E2 2011-01-16'
cp -a keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg
testsuccess --nomsg aptkey --fakeroot del DBAC8DAE
testaptkeys 'pub 2048R/528144E2 2011-01-16'
- testsuccess test ! -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+ testfailure test -e rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
testsuccess cmp keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg~
testsuccess cmp keys/testcase-multikey.pub rootdir/etc/apt/trusted.gpg.d/multikey.gpg~
diff --git a/test/integration/test-authentication-basic b/test/integration/test-authentication-basic
index 4b0ead54a..21b024970 100755
--- a/test/integration/test-authentication-basic
+++ b/test/integration/test-authentication-basic
@@ -18,7 +18,7 @@ testauthfailure() {
testfailure apthelper download-file "${1}/bash" ./downloaded/bash
# crappy test, but http and https output are wastely different…
testsuccess grep 401 rootdir/tmp/testfailure.output
- testsuccess test ! -s ./downloaded/bash
+ testfailure test -s ./downloaded/bash
}
testauthsuccess() {
diff --git a/test/integration/test-bug-738785-switch-protocol b/test/integration/test-bug-738785-switch-protocol
index e50c84dbf..0f458e099 100755
--- a/test/integration/test-bug-738785-switch-protocol
+++ b/test/integration/test-bug-738785-switch-protocol
@@ -54,7 +54,7 @@ echo "Dir::Bin::Methods \"${COPYMETHODS}\";" >> aptconfig.conf
cd downloaded
testequal "E: The method driver $(readlink -f './../')/rootdir/usr/lib/apt/methods/https could not be found.
N: Is the package apt-transport-https installed?" aptget download apt -q=0
-testsuccess test ! -e apt_1.0_all.deb
+testfailure test -e apt_1.0_all.deb
cd - >/dev/null
# revert to all methods