Blame SOURCES/0012-tests-shell-Fix-skip-checks-with-host-mode.patch

621646
From bbd2dd9ee6db7d11ab5b2b10a63b3dfd8b8acc9d Mon Sep 17 00:00:00 2001
621646
From: Phil Sutter <phil@nwl.cc>
621646
Date: Wed, 12 Feb 2020 21:26:06 +0100
621646
Subject: [PATCH] tests: shell: Fix skip checks with --host mode
621646
621646
When testing host binaries, XT_MULTI variable contains just the program
621646
name without path component which most skip checks didn't expect. Fix
621646
them, and while being at it also reduce indenting level in two scripts
621646
by moving the skip check up front with an early exit call.
621646
621646
Fixes: 416898e335322 ("tests/shell: Support testing host binaries")
621646
Signed-off-by: Phil Sutter <phil@nwl.cc>
621646
(cherry picked from commit 2b2b7948c1960ba4680677664ff58477be869de6)
621646
Signed-off-by: Phil Sutter <psutter@redhat.com>
621646
---
621646
 .../arptables/0001-arptables-save-restore_0   |   2 +-
621646
 .../0002-arptables-restore-defaults_0         |   2 +-
621646
 .../arptables/0003-arptables-verbose-output_0 |   2 +-
621646
 .../testcases/ebtables/0001-ebtables-basic_0  | 135 +++++++++---------
621646
 .../ebtables/0002-ebtables-save-restore_0     |   2 +-
621646
 .../ebtables/0003-ebtables-restore-defaults_0 |   2 +-
621646
 .../testcases/ebtables/0004-save-counters_0   |   2 +-
621646
 .../testcases/ebtables/0005-ifnamechecks_0    |   2 +-
621646
 .../firewalld-restore/0001-firewalld_0        |   2 +-
621646
 .../testcases/ipt-restore/0004-restore-race_0 |   2 +-
621646
 .../shell/testcases/nft-only/0001compat_0     |  15 +-
621646
 .../shell/testcases/nft-only/0002invflags_0   |   2 +-
621646
 .../nft-only/0003delete-with-comment_0        |   2 +-
621646
 13 files changed, 88 insertions(+), 84 deletions(-)
621646
621646
diff --git a/iptables/tests/shell/testcases/arptables/0001-arptables-save-restore_0 b/iptables/tests/shell/testcases/arptables/0001-arptables-save-restore_0
621646
index bf04dc0a3e15a..e64e9142ee98b 100755
621646
--- a/iptables/tests/shell/testcases/arptables/0001-arptables-save-restore_0
621646
+++ b/iptables/tests/shell/testcases/arptables/0001-arptables-save-restore_0
621646
@@ -4,7 +4,7 @@ set -e
621646
 #set -x
621646
 
621646
 # there is no legacy backend to test
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 # fill arptables manually
621646
 
621646
diff --git a/iptables/tests/shell/testcases/arptables/0002-arptables-restore-defaults_0 b/iptables/tests/shell/testcases/arptables/0002-arptables-restore-defaults_0
621646
index 38d387f327ebb..afd0fcb460d85 100755
621646
--- a/iptables/tests/shell/testcases/arptables/0002-arptables-restore-defaults_0
621646
+++ b/iptables/tests/shell/testcases/arptables/0002-arptables-restore-defaults_0
621646
@@ -3,7 +3,7 @@
621646
 set -e
621646
 
621646
 # there is no legacy backend to test
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 # arptables-restore reuses preloaded targets and matches, make sure defaults
621646
 # apply to consecutive rules using the same target/match as a previous one
621646
diff --git a/iptables/tests/shell/testcases/arptables/0003-arptables-verbose-output_0 b/iptables/tests/shell/testcases/arptables/0003-arptables-verbose-output_0
621646
index 10c5ec33ada2c..952cfa7898371 100755
621646
--- a/iptables/tests/shell/testcases/arptables/0003-arptables-verbose-output_0
621646
+++ b/iptables/tests/shell/testcases/arptables/0003-arptables-verbose-output_0
621646
@@ -4,7 +4,7 @@ set -e
621646
 set -x
621646
 
621646
 # there is no legacy backend to test
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 $XT_MULTI arptables -N foo
621646
 
621646
diff --git a/iptables/tests/shell/testcases/ebtables/0001-ebtables-basic_0 b/iptables/tests/shell/testcases/ebtables/0001-ebtables-basic_0
621646
index c7f24a383f698..0c1eb4ca66f52 100755
621646
--- a/iptables/tests/shell/testcases/ebtables/0001-ebtables-basic_0
621646
+++ b/iptables/tests/shell/testcases/ebtables/0001-ebtables-basic_0
621646
@@ -1,86 +1,89 @@
621646
 #!/bin/sh
621646
 
621646
+case "$XT_MULTI" in
621646
+*xtables-nft-multi)
621646
+	;;
621646
+*)
621646
+	echo "skip $XT_MULTI"
621646
+	exit 0
621646
+	;;
621646
+esac
621646
+
621646
 get_entries_count() { # (chain)
621646
 	$XT_MULTI ebtables -L $1 | sed -n 's/.*entries: \([0-9]*\).*/\1/p'
621646
 }
621646
 
621646
 set -x
621646
-case "$XT_MULTI" in
621646
-*/xtables-nft-multi)
621646
-	for t in filter nat;do
621646
-		$XT_MULTI ebtables -t $t -L || exit 1
621646
-		$XT_MULTI ebtables -t $t -X || exit 1
621646
-		$XT_MULTI ebtables -t $t -F || exit 1
621646
-	done
621646
-
621646
-	for t in broute foobar ;do
621646
-		$XT_MULTI ebtables -t $t -L &&
621646
-		$XT_MULTI ebtables -t $t -X &&
621646
-		$XT_MULTI ebtables -t $t -F
621646
-		if [ $? -eq 0 ]; then
621646
-			echo "Expect nonzero return for unsupported table"
621646
-			exit 1
621646
-		fi
621646
-	done
621646
 
621646
+for t in filter nat;do
621646
+	$XT_MULTI ebtables -t $t -L || exit 1
621646
+	$XT_MULTI ebtables -t $t -X || exit 1
621646
+	$XT_MULTI ebtables -t $t -F || exit 1
621646
+done
621646
 
621646
-	$XT_MULTI ebtables -t filter -N FOO || exit 1
621646
-	$XT_MULTI ebtables -t filter -N FOO
621646
+for t in broute foobar ;do
621646
+	$XT_MULTI ebtables -t $t -L &&
621646
+	$XT_MULTI ebtables -t $t -X &&
621646
+	$XT_MULTI ebtables -t $t -F
621646
 	if [ $? -eq 0 ]; then
621646
-		echo "Duplicate chain FOO"
621646
-		$XT_MULTI ebtables -t filter -L
621646
+		echo "Expect nonzero return for unsupported table"
621646
 		exit 1
621646
 	fi
621646
+done
621646
 
621646
-	entries=$(get_entries_count FOO)
621646
-	if [ $entries -ne 0 ]; then
621646
-		echo "Unexpected entries count in empty unreferenced chain (expected 0, have $entries)"
621646
-		$XT_MULTI ebtables -L
621646
-		exit 1
621646
-	fi
621646
 
621646
-	$XT_MULTI ebtables -A FORWARD -j FOO
621646
-	entries=$(get_entries_count FORWARD)
621646
-	if [ $entries -ne 1 ]; then
621646
-		echo "Unexpected entries count in FORWARD chain (expected 1, have $entries)"
621646
-		$XT_MULTI ebtables -L
621646
-		exit 1
621646
-	fi
621646
+$XT_MULTI ebtables -t filter -N FOO || exit 1
621646
+$XT_MULTI ebtables -t filter -N FOO
621646
+if [ $? -eq 0 ]; then
621646
+	echo "Duplicate chain FOO"
621646
+	$XT_MULTI ebtables -t filter -L
621646
+	exit 1
621646
+fi
621646
 
621646
-	entries=$(get_entries_count FOO)
621646
-	if [ $entries -ne 0 ]; then
621646
-		echo "Unexpected entries count in empty referenced chain (expected 0, have $entries)"
621646
-		$XT_MULTI ebtables -L
621646
-		exit 1
621646
-	fi
621646
+entries=$(get_entries_count FOO)
621646
+if [ $entries -ne 0 ]; then
621646
+	echo "Unexpected entries count in empty unreferenced chain (expected 0, have $entries)"
621646
+	$XT_MULTI ebtables -L
621646
+	exit 1
621646
+fi
621646
 
621646
-	$XT_MULTI ebtables -A FOO -j ACCEPT
621646
-	entries=$(get_entries_count FOO)
621646
-	if [ $entries -ne 1 ]; then
621646
-		echo "Unexpected entries count in non-empty referenced chain (expected 1, have $entries)"
621646
-		$XT_MULTI ebtables -L
621646
-		exit 1
621646
-	fi
621646
+$XT_MULTI ebtables -A FORWARD -j FOO
621646
+entries=$(get_entries_count FORWARD)
621646
+if [ $entries -ne 1 ]; then
621646
+	echo "Unexpected entries count in FORWARD chain (expected 1, have $entries)"
621646
+	$XT_MULTI ebtables -L
621646
+	exit 1
621646
+fi
621646
 
621646
-	$XT_MULTI ebtables -t filter -N BAR || exit 1
621646
-	$XT_MULTI ebtables -t filter -N BAZ || exit 1
621646
+entries=$(get_entries_count FOO)
621646
+if [ $entries -ne 0 ]; then
621646
+	echo "Unexpected entries count in empty referenced chain (expected 0, have $entries)"
621646
+	$XT_MULTI ebtables -L
621646
+	exit 1
621646
+fi
621646
 
621646
-	$XT_MULTI ebtables -t filter -L | grep -q FOO || exit 1
621646
-	$XT_MULTI ebtables -t filter -L | grep -q BAR || exit 1
621646
-	$XT_MULTI ebtables -t filter -L | grep -q BAZ || exit 1
621646
+$XT_MULTI ebtables -A FOO -j ACCEPT
621646
+entries=$(get_entries_count FOO)
621646
+if [ $entries -ne 1 ]; then
621646
+	echo "Unexpected entries count in non-empty referenced chain (expected 1, have $entries)"
621646
+	$XT_MULTI ebtables -L
621646
+	exit 1
621646
+fi
621646
 
621646
-	$XT_MULTI ebtables -t filter -L BAZ || exit 1
621646
-	$XT_MULTI ebtables -t filter -X BAZ || exit 1
621646
-	$XT_MULTI ebtables -t filter -L BAZ | grep -q BAZ
621646
-	if [ $? -eq 0 ]; then
621646
-		echo "Deleted chain -L BAZ ok, expected failure"
621646
-		$XT_MULTI ebtables -t filter -L
621646
-		exit 1
621646
-	fi
621646
+$XT_MULTI ebtables -t filter -N BAR || exit 1
621646
+$XT_MULTI ebtables -t filter -N BAZ || exit 1
621646
 
621646
-	$XT_MULTI ebtables -t $t -F || exit 0
621646
-	;;
621646
-*)
621646
-	echo "skip $XT_MULTI"
621646
-	;;
621646
-esac
621646
+$XT_MULTI ebtables -t filter -L | grep -q FOO || exit 1
621646
+$XT_MULTI ebtables -t filter -L | grep -q BAR || exit 1
621646
+$XT_MULTI ebtables -t filter -L | grep -q BAZ || exit 1
621646
+
621646
+$XT_MULTI ebtables -t filter -L BAZ || exit 1
621646
+$XT_MULTI ebtables -t filter -X BAZ || exit 1
621646
+$XT_MULTI ebtables -t filter -L BAZ | grep -q BAZ
621646
+if [ $? -eq 0 ]; then
621646
+	echo "Deleted chain -L BAZ ok, expected failure"
621646
+	$XT_MULTI ebtables -t filter -L
621646
+	exit 1
621646
+fi
621646
+
621646
+$XT_MULTI ebtables -t $t -F || exit 0
621646
diff --git a/iptables/tests/shell/testcases/ebtables/0002-ebtables-save-restore_0 b/iptables/tests/shell/testcases/ebtables/0002-ebtables-save-restore_0
621646
index e18d46551509d..b84f63a7c3672 100755
621646
--- a/iptables/tests/shell/testcases/ebtables/0002-ebtables-save-restore_0
621646
+++ b/iptables/tests/shell/testcases/ebtables/0002-ebtables-save-restore_0
621646
@@ -4,7 +4,7 @@ set -e
621646
 #set -x
621646
 
621646
 # there is no legacy backend to test
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 # fill ebtables manually
621646
 
621646
diff --git a/iptables/tests/shell/testcases/ebtables/0003-ebtables-restore-defaults_0 b/iptables/tests/shell/testcases/ebtables/0003-ebtables-restore-defaults_0
621646
index 62d224134456b..63891c1bb731a 100755
621646
--- a/iptables/tests/shell/testcases/ebtables/0003-ebtables-restore-defaults_0
621646
+++ b/iptables/tests/shell/testcases/ebtables/0003-ebtables-restore-defaults_0
621646
@@ -3,7 +3,7 @@
621646
 set -e
621646
 
621646
 # there is no legacy backend to test
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 # ebtables-restore reuses preloaded targets and matches, make sure defaults
621646
 # apply to consecutive rules using the same target/match as a previous one
621646
diff --git a/iptables/tests/shell/testcases/ebtables/0004-save-counters_0 b/iptables/tests/shell/testcases/ebtables/0004-save-counters_0
621646
index 46966f433139a..d52db900604ef 100755
621646
--- a/iptables/tests/shell/testcases/ebtables/0004-save-counters_0
621646
+++ b/iptables/tests/shell/testcases/ebtables/0004-save-counters_0
621646
@@ -3,7 +3,7 @@
621646
 set -e
621646
 
621646
 # there is no legacy backend to test
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 $XT_MULTI ebtables --init-table
621646
 $XT_MULTI ebtables -A FORWARD -i nodev123 -o nodev432 -j ACCEPT
621646
diff --git a/iptables/tests/shell/testcases/ebtables/0005-ifnamechecks_0 b/iptables/tests/shell/testcases/ebtables/0005-ifnamechecks_0
621646
index 2163d364b318b..0b3acfd7613db 100755
621646
--- a/iptables/tests/shell/testcases/ebtables/0005-ifnamechecks_0
621646
+++ b/iptables/tests/shell/testcases/ebtables/0005-ifnamechecks_0
621646
@@ -3,7 +3,7 @@
621646
 set -e
621646
 
621646
 # there is no legacy backend to test
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 EXPECT='*filter
621646
 :INPUT ACCEPT
621646
diff --git a/iptables/tests/shell/testcases/firewalld-restore/0001-firewalld_0 b/iptables/tests/shell/testcases/firewalld-restore/0001-firewalld_0
621646
index 8bf0c2c6c194e..0174b03f4ebc7 100755
621646
--- a/iptables/tests/shell/testcases/firewalld-restore/0001-firewalld_0
621646
+++ b/iptables/tests/shell/testcases/firewalld-restore/0001-firewalld_0
621646
@@ -231,7 +231,7 @@ for table in nat mangle raw filter;do
621646
 done
621646
 
621646
 case "$XT_MULTI" in
621646
-*/xtables-nft-multi)
621646
+*xtables-nft-multi)
621646
 	# nft-multi displays chain names in different order, work around this for now
621646
 	tmpfile2=$(mktemp)
621646
 	sort "$tmpfile" > "$tmpfile2"
621646
diff --git a/iptables/tests/shell/testcases/ipt-restore/0004-restore-race_0 b/iptables/tests/shell/testcases/ipt-restore/0004-restore-race_0
621646
index 96a5e66d0ab81..9fc50615b8926 100755
621646
--- a/iptables/tests/shell/testcases/ipt-restore/0004-restore-race_0
621646
+++ b/iptables/tests/shell/testcases/ipt-restore/0004-restore-race_0
621646
@@ -86,7 +86,7 @@ if [ $LINES1 -ne $LINES2 ]; then
621646
 fi
621646
 
621646
 case "$XT_MULTI" in
621646
-*/xtables-nft-multi)
621646
+*xtables-nft-multi)
621646
 	attempts=$((RANDOM%10))
621646
 	attempts=$((attempts+1))
621646
 	;;
621646
diff --git a/iptables/tests/shell/testcases/nft-only/0001compat_0 b/iptables/tests/shell/testcases/nft-only/0001compat_0
621646
index 4319ea5a6a797..a617c52f53695 100755
621646
--- a/iptables/tests/shell/testcases/nft-only/0001compat_0
621646
+++ b/iptables/tests/shell/testcases/nft-only/0001compat_0
621646
@@ -5,17 +5,18 @@
621646
 # xtables: avoid bogus 'is incompatible' warning
621646
 
621646
 case "$XT_MULTI" in
621646
-*/xtables-nft-multi)
621646
-	nft -v >/dev/null || exit 0
621646
-	nft 'add table ip nft-test; add chain ip nft-test foobar { type filter hook forward priority 42;  }' || exit 1
621646
-	nft 'add table ip6 nft-test; add chain ip6 nft-test foobar { type filter hook forward priority 42;  }' || exit 1
621646
-
621646
-	$XT_MULTI iptables -L -t filter || exit 1
621646
-	$XT_MULTI ip6tables -L -t filter || exit 1
621646
+*xtables-nft-multi)
621646
 	;;
621646
 *)
621646
 	echo skip $XT_MULTI
621646
+	exit 0
621646
 	;;
621646
 esac
621646
 
621646
+nft -v >/dev/null || exit 0
621646
+nft 'add table ip nft-test; add chain ip nft-test foobar { type filter hook forward priority 42;  }' || exit 1
621646
+nft 'add table ip6 nft-test; add chain ip6 nft-test foobar { type filter hook forward priority 42;  }' || exit 1
621646
+
621646
+$XT_MULTI iptables -L -t filter || exit 1
621646
+$XT_MULTI ip6tables -L -t filter || exit 1
621646
 exit 0
621646
diff --git a/iptables/tests/shell/testcases/nft-only/0002invflags_0 b/iptables/tests/shell/testcases/nft-only/0002invflags_0
621646
index 406b6081a98a4..fe33874dde7f2 100755
621646
--- a/iptables/tests/shell/testcases/nft-only/0002invflags_0
621646
+++ b/iptables/tests/shell/testcases/nft-only/0002invflags_0
621646
@@ -2,7 +2,7 @@
621646
 
621646
 set -e
621646
 
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 $XT_MULTI iptables -A INPUT -p tcp --dport 53 ! -s 192.168.0.1 -j ACCEPT
621646
 $XT_MULTI ip6tables -A INPUT -p tcp --dport 53 ! -s feed:babe::1 -j ACCEPT
621646
diff --git a/iptables/tests/shell/testcases/nft-only/0003delete-with-comment_0 b/iptables/tests/shell/testcases/nft-only/0003delete-with-comment_0
621646
index 67af9fd897410..ccb009e469076 100755
621646
--- a/iptables/tests/shell/testcases/nft-only/0003delete-with-comment_0
621646
+++ b/iptables/tests/shell/testcases/nft-only/0003delete-with-comment_0
621646
@@ -2,7 +2,7 @@
621646
 
621646
 set -e
621646
 
621646
-[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
+[[ $XT_MULTI == *xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
621646
 
621646
 comment1="foo bar"
621646
 comment2="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
621646
-- 
621646
2.24.1
621646