diff options
author | Phil Sutter <phil@nwl.cc> | 2019-02-19 20:39:50 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2019-02-22 16:54:52 +0100 |
commit | 416898e33532206dd41f243f35d38d79a78c9b36 (patch) | |
tree | 0b23f27c05ab2cde85b3a6766061c3eb553c64e8 /iptables/tests/shell/run-tests.sh | |
parent | 59372f0c4f2e93b7633ab418536874343e023db7 (diff) |
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 <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables/tests/shell/run-tests.sh')
-rwxr-xr-x | iptables/tests/shell/run-tests.sh | 48 |
1 files changed, 32 insertions, 16 deletions
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 |