]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: allow test options to be overridden by env
authorRuediger Meier <ruediger.meier@ga-group.nl>
Sat, 10 May 2014 00:00:53 +0000 (02:00 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Sat, 10 May 2014 03:56:43 +0000 (05:56 +0200)
Specially for automated builds the user may want to have some
fine granulated influence like

export TS_OPT_libmount_verbose="yes"
export TS_OPT_ipcs_fake="yes"
export TS_OPT_ipcs_limits2_fake="no"
if <big endian> then
  export TS_OPT_hexdump_fake="yes"
fi
make check

Even for interactive developers this could be useful for example to
debug just one particuar test while having a regular run with stress:

TS_OPT_script_verbose="yes" \
TS_OPT_script_memcheck="yes" \
../tests/run.sh --parallel=256 --srcdir=.. --builddir=. --nonroot

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tests/functions.sh

index e76408baf9a4a58147b16d8ceafd0ed1784ac144..0366f163b502367094e69911da5adaeedfec01d3 100644 (file)
@@ -97,6 +97,21 @@ function ts_log {
 function ts_has_option {
        NAME="$1"
        ALL="$2"
+
+       # user may set options by env for a single test or whole component
+       # e.g. TS_OPT_ipcs_limits2_fake="yes" or TS_OPT_ipcs_fake="yes"
+       eval local env_opt_test=\$TS_OPT_${TS_COMPONENT}_${TS_TESTNAME}_${NAME}
+       eval local env_opt_comp=\$TS_OPT_${TS_COMPONENT}_${NAME}
+       if [ "$env_opt_test" = "yes" \
+               -o "$env_opt_comp" = "yes" -a "$env_opt_test" != "no" ]; then
+               echo "yes"
+               return
+       elif [ "$env_opt_test" = "no" \
+               -o "$env_opt_comp" = "no" -a "$env_opt_test" != "yes" ]; then
+               return
+       fi
+
+       # or just check the global command line options
        echo -n $ALL | sed 's/ //g' | awk 'BEGIN { FS="="; RS="--" } /('$NAME'$|'$NAME'=)/ { print "yes" }'
 }