diff options
author | Karel Zak <kzak@redhat.com> | 2010-10-20 12:40:02 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2011-01-03 12:28:45 +0100 |
commit | db17c74bc464eceba62fbf4bb30d75e1e544d8e8 (patch) | |
tree | a991125655df4494ddd3bfa1022675689329d806 /tests | |
parent | 1bd1cd2c6c02269708f4418b0056b49a53a16ed1 (diff) | |
download | util-linux-old-db17c74bc464eceba62fbf4bb30d75e1e544d8e8.tar.gz |
tests: improve subtests initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functions.sh | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/tests/functions.sh b/tests/functions.sh index 92b3ee4b..7c74b016 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -75,6 +75,22 @@ function ts_has_option { echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }' } +function ts_init_core_env { + TS_NS="$TS_COMPONENT/$TS_TESTNAME" + TS_OUTPUT="$TS_OUTDIR/$TS_TESTNAME" + TS_DIFF="$TS_DIFFDIR/$TS_TESTNAME" + TS_EXPECTED="$TS_TOPDIR/expected/$TS_NS" + TS_MOUNTPOINT="$TS_OUTDIR/${TS_TESTNAME}-mnt" +} + +function ts_init_core_subtest_env { + TS_NS="$TS_COMPONENT/$TS_TESTNAME-$TS_SUBNAME" + TS_OUTPUT="$TS_OUTDIR/$TS_TESTNAME-$TS_SUBNAME" + TS_DIFF="$TS_DIFFDIR/$TS_TESTNAME-$TS_SUBNAME" + TS_EXPECTED="$TS_TOPDIR/expected/$TS_NS" + TS_MOUNTPOINT="$TS_OUTDIR/${TS_TESTNAME-$TS_SUBNAME}-mnt" +} + function ts_init_env { local mydir=$(ts_abspath $(dirname $0)) @@ -94,15 +110,12 @@ function ts_init_env { TS_NSUBTESTS=0 TS_NSUBFAILED=0 - TS_NS="$TS_COMPONENT/$TS_TESTNAME" TS_SELF="$TS_SUBDIR" TS_OUTDIR="$TS_TOPDIR/output/$TS_COMPONENT" - TS_OUTPUT="$TS_OUTDIR/$TS_TESTNAME" TS_DIFFDIR="$TS_TOPDIR/diff/$TS_COMPONENT" - TS_DIFF="$TS_DIFFDIR/$TS_TESTNAME" - TS_EXPECTED="$TS_TOPDIR/expected/$TS_NS" - TS_MOUNTPOINT="$TS_OUTDIR/${TS_TESTNAME}-mnt" + + ts_init_core_env TS_VERBOSE=$(ts_has_option "verbose" "$*") @@ -144,10 +157,7 @@ function ts_init_subtest { TS_SUBNAME="$1" - TS_OUTPUT="$TS_OUTDIR/$TS_TESTNAME-$TS_SUBNAME" - TS_DIFF="$TS_DIFFDIR/$TS_TESTNAME-$TS_SUBNAME" - TS_EXPECTED="$TS_TOPDIR/expected/$TS_NS-$TS_SUBNAME" - TS_MOUNTPOINT="$TS_OUTDIR/${TS_TESTNAME-$TS_SUBNAME}-mnt" + ts_init_core_subtest_env [ $TS_NSUBTESTS -eq 0 ] && echo TS_NSUBTESTS=$(( $TS_NSUBTESTS + 1 )) @@ -206,6 +216,10 @@ function ts_finalize_subtest { fi [ $res -ne 0 ] && TS_NSUBFAILED=$(( $TS_NSUBFAILED + 1 )) + + # reset environment back to parental test + ts_init_core_env + return $res } |