]> err.no Git - util-linux/commitdiff
tests: improve subtests initialization
authorKarel Zak <kzak@redhat.com>
Wed, 20 Oct 2010 10:40:02 +0000 (12:40 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:45 +0000 (12:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh

index 92b3ee4b6b9cc1fff2f1ffea1e923c5a904b1ade..7c74b0166bfc60f66c0e7d458546a3ec022d6db4 100644 (file)
@@ -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
 }