tests: fix options evaluation, add support for optional tests
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
fa7be20eb9
commit
949cf64bbc
|
@ -168,12 +168,14 @@ function ts_init_subtest {
|
||||||
|
|
||||||
function ts_init {
|
function ts_init {
|
||||||
local is_fake=$( ts_has_option "fake" "$*")
|
local is_fake=$( ts_has_option "fake" "$*")
|
||||||
|
local is_force=$( ts_has_option "force" "$*")
|
||||||
|
|
||||||
ts_init_env "$*"
|
ts_init_env "$*"
|
||||||
|
|
||||||
printf "%13s: %-30s ..." "$TS_COMPONENT" "$TS_DESC"
|
printf "%13s: %-30s ..." "$TS_COMPONENT" "$TS_DESC"
|
||||||
|
|
||||||
[ "$is_fake" == "yes" ] && ts_skip "fake mode"
|
[ "$is_fake" == "yes" ] && ts_skip "fake mode"
|
||||||
|
[ "$TS_OPTIONAL" == "yes" -a "$is_force" != "yes" ] && ts_skip "optional"
|
||||||
}
|
}
|
||||||
|
|
||||||
function ts_init_suid {
|
function ts_init_suid {
|
||||||
|
|
51
tests/run.sh
51
tests/run.sh
|
@ -17,21 +17,44 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
TS_TOPDIR=$(cd $(dirname $0) && pwd)
|
TS_TOPDIR=$(cd $(dirname $0) && pwd)
|
||||||
comps=$(find $TS_TOPDIR/ts/ -type f -perm /a+x -regex ".*/[^\.~]*" | sort)
|
SUBTESTS=
|
||||||
|
OPTS=
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
while [ -n "$1" ]; do
|
||||||
if [ -d "$TS_TOPDIR/ts/$1" ]; then
|
case "$1" in
|
||||||
comps=$(find $TS_TOPDIR/ts/$1 -type f -perm /a+x -regex ".*/[^\.~]*" | sort)
|
--force)
|
||||||
else
|
OPTS="$OPTS --force"
|
||||||
echo
|
;;
|
||||||
echo "usage: $0 [<component>]"
|
--fake)
|
||||||
echo "supported components:"
|
OPTS="$OPTS --fake"
|
||||||
for ts in $comps; do
|
;;
|
||||||
echo -e "\t$(basename $(dirname $ts))"
|
--*)
|
||||||
done | sort -u
|
echo "Unknown option $1"
|
||||||
echo
|
echo "Usage: run [--fake] [--force] [<component> ...]"
|
||||||
exit 1
|
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
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -44,7 +67,7 @@ echo
|
||||||
res=0
|
res=0
|
||||||
count=0
|
count=0
|
||||||
for ts in $comps; do
|
for ts in $comps; do
|
||||||
$ts "$1"
|
$ts "$OPTS"
|
||||||
res=$(( $res + $? ))
|
res=$(( $res + $? ))
|
||||||
count=$(( $count + 1 ))
|
count=$(( $count + 1 ))
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue