From 1df24acfdb8ba1cd8bbbaa166f170dda480ce41e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 19 Oct 2014 14:14:37 +0200 Subject: 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 --- test/integration/framework | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'test/integration/framework') 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' "$@" } -- cgit v1.2.3