diff options
author | Phil Sutter <phil@nwl.cc> | 2020-01-14 16:50:35 +0100 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2020-01-16 16:06:14 +0100 |
commit | 68310ba0f9c2066f7463d66a1a1938b66fb8a4c4 (patch) | |
tree | e1ce9632323f2cfc2d4a061d6e433ddd48dc17ec /tests/shell/testcases/netns | |
parent | 488356b895024d0944b20feb1f930558726e0877 (diff) |
tests: shell: Search diff tool once and for all
Instead of calling 'which diff' over and over again, just detect the
tool's presence in run-tests.sh and pass $DIFF to each testcase just
like with nft binary.
Fall back to using 'true' command to avoid the need for any conditional
calling in test cases.
While being at it, unify potential diff calls so that a string
comparison in shell happens irrespective of diff presence.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/shell/testcases/netns')
-rwxr-xr-x | tests/shell/testcases/netns/0001nft-f_0 | 3 | ||||
-rwxr-xr-x | tests/shell/testcases/netns/0002loosecommands_0 | 3 | ||||
-rwxr-xr-x | tests/shell/testcases/netns/0003many_0 | 3 |
3 files changed, 3 insertions, 6 deletions
diff --git a/tests/shell/testcases/netns/0001nft-f_0 b/tests/shell/testcases/netns/0001nft-f_0 index 81942263..a591f2cd 100755 --- a/tests/shell/testcases/netns/0001nft-f_0 +++ b/tests/shell/testcases/netns/0001nft-f_0 @@ -93,8 +93,7 @@ fi KERNEL_RULESET="$($IP netns exec $NETNS_NAME $NFT list ruleset)" $IP netns del $NETNS_NAME if [ "$RULESET" != "$KERNEL_RULESET" ] ; then - DIFF="$(which diff)" - [ -x $DIFF ] && $DIFF -u <(echo "$RULESET") <(echo "$KERNEL_RULESET") + $DIFF -u <(echo "$RULESET") <(echo "$KERNEL_RULESET") exit 1 fi exit 0 diff --git a/tests/shell/testcases/netns/0002loosecommands_0 b/tests/shell/testcases/netns/0002loosecommands_0 index 465c2e86..231f1fb7 100755 --- a/tests/shell/testcases/netns/0002loosecommands_0 +++ b/tests/shell/testcases/netns/0002loosecommands_0 @@ -56,7 +56,6 @@ RULESET="table ip t { KERNEL_RULESET="$($IP netns exec $NETNS_NAME $NFT list ruleset)" $IP netns del $NETNS_NAME if [ "$RULESET" != "$KERNEL_RULESET" ] ; then - DIFF="$(which diff)" - [ -x $DIFF ] && $DIFF -u <(echo "$RULESET") <(echo "$KERNEL_RULESET") + $DIFF -u <(echo "$RULESET") <(echo "$KERNEL_RULESET") exit 1 fi diff --git a/tests/shell/testcases/netns/0003many_0 b/tests/shell/testcases/netns/0003many_0 index a5fcb5d6..afe9117d 100755 --- a/tests/shell/testcases/netns/0003many_0 +++ b/tests/shell/testcases/netns/0003many_0 @@ -97,8 +97,7 @@ function test_netns() KERNEL_RULESET="$($IP netns exec $NETNS_NAME $NFT list ruleset)" if [ "$RULESET" != "$KERNEL_RULESET" ] ; then echo "E: ruleset in netns $NETNS_NAME differs from the loaded" >&2 - DIFF="$(which diff)" - [ -x $DIFF ] && $DIFF -u <(echo "$RULESET") <(echo "$KERNEL_RULESET") + $DIFF -u <(echo "$RULESET") <(echo "$KERNEL_RULESET") $IP netns del $NETNS_NAME exit 1 fi |