From 68310ba0f9c2066f7463d66a1a1938b66fb8a4c4 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 14 Jan 2020 16:50:35 +0100 Subject: 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 Acked-by: Pablo Neira Ayuso --- .../shell/testcases/rule_management/0001addinsertposition_0 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tests/shell/testcases/rule_management') diff --git a/tests/shell/testcases/rule_management/0001addinsertposition_0 b/tests/shell/testcases/rule_management/0001addinsertposition_0 index bb3fda51..237e9e32 100755 --- a/tests/shell/testcases/rule_management/0001addinsertposition_0 +++ b/tests/shell/testcases/rule_management/0001addinsertposition_0 @@ -30,8 +30,7 @@ for arg in "position 2" "handle 2" "index 0"; do GET="$($NFT list ruleset)" if [ "$EXPECTED" != "$GET" ] ; then - DIFF="$(which diff)" - [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET") + $DIFF -u <(echo "$EXPECTED") <(echo "$GET") exit 1 fi done @@ -42,8 +41,7 @@ for arg in "position 3" "handle 3" "index 1"; do GET="$($NFT list ruleset)" if [ "$EXPECTED" != "$GET" ] ; then - DIFF="$(which diff)" - [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET") + $DIFF -u <(echo "$EXPECTED") <(echo "$GET") exit 1 fi done @@ -62,8 +60,7 @@ for arg in "position 3" "handle 3" "index 1"; do GET="$($NFT list ruleset)" if [ "$EXPECTED" != "$GET" ] ; then - DIFF="$(which diff)" - [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET") + $DIFF -u <(echo "$EXPECTED") <(echo "$GET") exit 1 fi done @@ -82,8 +79,7 @@ for arg in "position 2" "handle 2" "index 0"; do GET="$($NFT list ruleset)" if [ "$EXPECTED" != "$GET" ] ; then - DIFF="$(which diff)" - [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET") + $DIFF -u <(echo "$EXPECTED") <(echo "$GET") exit 1 fi done -- cgit v1.2.3