]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: fix options evaluation, add support for optional tests
authorKarel Zak <kzak@redhat.com>
Thu, 3 Nov 2011 12:20:24 +0000 (13:20 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 3 Nov 2011 12:20:24 +0000 (13:20 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
tests/functions.sh
tests/run.sh

index 71ff7da0abd6e2102e8f4f1c34fce11455f51b63..bc658ba9a98f11496ff7276e1dadd82cc38c4007 100644 (file)
@@ -168,12 +168,14 @@ function ts_init_subtest {
 
 function ts_init {
        local is_fake=$( ts_has_option "fake" "$*")
+       local is_force=$( ts_has_option "force" "$*")
 
        ts_init_env "$*"
 
        printf "%13s: %-30s ..." "$TS_COMPONENT" "$TS_DESC"
 
        [ "$is_fake" == "yes" ] && ts_skip "fake mode"
+       [ "$TS_OPTIONAL" == "yes" -a "$is_force" != "yes" ] && ts_skip "optional"
 }
 
 function ts_init_suid {
index d7aa7ddccbfd83dbe36d898700de64ebda2246c9..f1ec3328aa78b2c25d7e298f5b06422870ad25cb 100755 (executable)
 #
 
 TS_TOPDIR=$(cd $(dirname $0) && pwd)
-comps=$(find $TS_TOPDIR/ts/ -type f -perm /a+x -regex ".*/[^\.~]*" |  sort)
-
-if [ -n "$1" ]; then
-       if [ -d "$TS_TOPDIR/ts/$1" ]; then
-               comps=$(find $TS_TOPDIR/ts/$1 -type f -perm /a+x -regex ".*/[^\.~]*" |  sort)
-       else
-               echo
-               echo "usage: $0 [<component>]"
-               echo "supported components:"
-                       for ts in $comps; do
-                               echo -e "\t$(basename $(dirname $ts))"
-                       done | sort -u
-               echo
+SUBTESTS=
+OPTS=
+
+while [ -n "$1" ]; do
+       case "$1" in
+       --force)
+               OPTS="$OPTS --force"
+               ;;
+       --fake)
+               OPTS="$OPTS --fake"
+               ;;
+       --*)
+               echo "Unknown option $1"
+               echo "Usage: run [--fake] [--force] [<component> ...]"
                exit 1
-       fi
+               ;;
+
+       *)
+               SUBTESTS="$SUBTESTS $1"
+               ;;
+       esac
+       shift
+done
+
+if [ -n "$SUBTESTS" ]; then
+       # selected tests only
+       for s in $SUBTESTS; do
+               if [ -d "$TS_TOPDIR/ts/$s" ]; then
+                       co=$(find $TS_TOPDIR/ts/$s -type f -perm /a+x -regex ".*/[^\.~]*" |  sort)
+                       comps="$comps $co"
+               else
+                       echo "Unknown test component '$s'"
+                       exit 1
+               fi
+       done
+else
+       # all tests
+       comps=$(find $TS_TOPDIR/ts/ -type f -perm /a+x -regex ".*/[^\.~]*" |  sort)
 fi
 
 echo
@@ -44,7 +67,7 @@ echo
 res=0
 count=0
 for ts in $comps; do
-       $ts "$1"
+       $ts "$OPTS"
        res=$(( $res + $? ))
        count=$(( $count + 1 ))
 done