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

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