diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-10-19 14:14:37 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-10-20 10:37:46 +0200 |
commit | 1df24acfdb8ba1cd8bbbaa166f170dda480ce41e (patch) | |
tree | 992b2cc2f5f02a34a49b5bac160070ec30cf34b1 /test/integration/framework | |
parent | cecc5532b8d64394a8f8641e78f4a0cc5f7a51fc (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/integration/framework')
-rw-r--r-- | test/integration/framework | 29 |
1 files changed, 25 insertions, 4 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' "$@" } |