summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorRuediger Meier2016-03-05 18:51:59 +0100
committerRuediger Meier2016-03-07 23:34:24 +0100
commit7e604f3c804a5718b1c591eb32043d140f052803 (patch)
tree4774fa8814528798eb9971a715bff7315af82597 /tests/functions.sh
parenttests: cramfs, fix root group (diff)
downloadkernel-qcow2-util-linux-7e604f3c804a5718b1c591eb32043d140f052803.tar.gz
kernel-qcow2-util-linux-7e604f3c804a5718b1c591eb32043d140f052803.tar.xz
kernel-qcow2-util-linux-7e604f3c804a5718b1c591eb32043d140f052803.zip
tests: don't skip case "output undefined"
Treat missing expected files as empty and let the test fail if there is non-empty output. Expected output may be missing in these cases: 1. forgot to commit the file after changing/adding a (sub)test 2. a bug in a test where we do tricks with TS_EXPECTED 3. and most notable if ts_die() is called before a subtest is initialized, e.g. in ts_scsi_debug_init() I always wondered why we don't treat this as FAILED. Now we do so, ts_finalize and ts_gen_diff looks much cleaner now. The change discovers that tests with subtest were ignoring the "non-sub" expected files which had to be fixed. BTW we removed any zero sized files. Moreover now we respect diff's return value. In past all test succeeded when diff was not able to write to diffdir, e.g. when running tests as normal user after they run as root. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'tests/functions.sh')
-rw-r--r--tests/functions.sh48
1 files changed, 18 insertions, 30 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index 9e5d24325..5d54efd96 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -378,22 +378,21 @@ function ts_valgrind {
function ts_gen_diff {
local res=0
- if [ -s "$TS_OUTPUT" ]; then
+ [ -f "$TS_OUTPUT" ] || return 1
+ [ -f "$TS_EXPECTED" ] || TS_EXPECTED=/dev/null
- # remove libtool lt- prefixes
- sed --in-place 's/^lt\-\(.*\: \)/\1/g' $TS_OUTPUT
+ # remove libtool lt- prefixes
+ sed --in-place 's/^lt\-\(.*\: \)/\1/g' $TS_OUTPUT
- [ -d "$TS_DIFFDIR" ] || mkdir -p "$TS_DIFFDIR"
- diff -u $TS_EXPECTED $TS_OUTPUT > $TS_DIFF
+ [ -d "$TS_DIFFDIR" ] || mkdir -p "$TS_DIFFDIR"
+ diff -u $TS_EXPECTED $TS_OUTPUT > $TS_DIFF
- if [ -s $TS_DIFF ]; then
- res=1
- else
- rm -f $TS_DIFF;
- fi
- else
+ if [ $? -ne 0 ] || [ -s $TS_DIFF ]; then
res=1
+ else
+ rm -f $TS_DIFF;
fi
+
return $res
}
@@ -409,16 +408,12 @@ function tt_gen_mem_report {
function ts_finalize_subtest {
local res=0
- if [ -s "$TS_EXPECTED" ]; then
- ts_gen_diff
- if [ $? -eq 1 ]; then
- ts_failed_subtest "$1"
- res=1
- else
- ts_ok_subtest "$(tt_gen_mem_report "$1")"
- fi
+ ts_gen_diff
+ if [ $? -eq 1 ]; then
+ ts_failed_subtest "$1"
+ res=1
else
- ts_skip_subtest "output undefined"
+ ts_ok_subtest "$(tt_gen_mem_report "$1")"
fi
[ $res -ne 0 ] && TS_NSUBFAILED=$(( $TS_NSUBFAILED + 1 ))
@@ -433,22 +428,15 @@ function ts_finalize {
ts_cleanup_on_exit
if [ $TS_NSUBTESTS -ne 0 ]; then
- if [ $TS_NSUBFAILED -ne 0 ]; then
+ if ! ts_gen_diff || [ $TS_NSUBFAILED -ne 0 ]; then
ts_failed "$TS_NSUBFAILED from $TS_NSUBTESTS sub-tests"
else
ts_ok "all $TS_NSUBTESTS sub-tests PASSED"
fi
fi
- if [ -s $TS_EXPECTED ]; then
- ts_gen_diff
- if [ $? -eq 1 ]; then
- ts_failed "$1"
- fi
- ts_ok "$1"
- fi
-
- ts_skip "output undefined"
+ ts_gen_diff || ts_failed "$1"
+ ts_ok "$1"
}
function ts_die {