From 416898e33532206dd41f243f35d38d79a78c9b36 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 19 Feb 2019 20:39:50 +0100 Subject: tests/shell: Support testing host binaries Add -H/--host parameter to run the testsuite against host system's binaries. While being at it, rewrite parameter parsing: * Parse all parameters in a loop, this frees any ordering constraints. * Set extglob option so strict pattern matching for single testcase mode can be done via bash globbing. Signed-off-by: Phil Sutter Signed-off-by: Florian Westphal --- iptables/tests/shell/run-tests.sh | 48 ++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'iptables/tests') diff --git a/iptables/tests/shell/run-tests.sh b/iptables/tests/shell/run-tests.sh index b6eb01c6..7bef09f7 100755 --- a/iptables/tests/shell/run-tests.sh +++ b/iptables/tests/shell/run-tests.sh @@ -3,10 +3,6 @@ #configuration TESTDIR="./$(dirname $0)/" RETURNCODE_SEPARATOR="_" -XTABLES_NFT_MULTI="$(dirname $0)/../../xtables-nft-multi" -XTABLES_LEGACY_MULTI="$(dirname $0)/../../xtables-legacy-multi" - -export XTABLES_LIBDIR=${TESTDIR}/../../../extensions msg_error() { echo "E: $1 ..." >&2 @@ -29,20 +25,40 @@ if [ ! -d "$TESTDIR" ] ; then msg_error "missing testdir $TESTDIR" fi -if [ "$1" == "-v" ] ; then - VERBOSE=y - shift -fi - -for arg in "$@"; do - if grep ^.*${RETURNCODE_SEPARATOR}[0-9]\\+$ <<< $arg >/dev/null ; then - SINGLE+=" $arg" - VERBOSE=y - else - msg_error "unknown parameter '$arg'" - fi +# support matching repeated pattern in SINGLE check below +shopt -s extglob + +while [ -n "$1" ]; do + case "$1" in + -v|--verbose) + VERBOSE=y + shift + ;; + -H|--host) + HOST=y + shift + ;; + *${RETURNCODE_SEPARATOR}+([0-9])) + SINGLE+=" $1" + VERBOSE=y + shift + ;; + *) + msg_error "unknown parameter '$1'" + ;; + esac done +if [ "$HOST" != "y" ]; then + XTABLES_NFT_MULTI="$(dirname $0)/../../xtables-nft-multi" + XTABLES_LEGACY_MULTI="$(dirname $0)/../../xtables-legacy-multi" + + export XTABLES_LIBDIR=${TESTDIR}/../../../extensions +else + XTABLES_NFT_MULTI="xtables-nft-multi" + XTABLES_LEGACY_MULTI="xtables-legacy-multi" +fi + find_tests() { if [ ! -z "$SINGLE" ] ; then echo $SINGLE -- cgit v1.2.3