Skip to contentSkip to conversation

tests/shell: add tests for deletion of chains via chain handle

PATCH New Harsha Sharma 1 participant 1 message Jan 14, 2018 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/shell: add tests for deletion of chains via chain handle

Delete chain with given unique handle for a table.

---
 tests/shell/testcases/chains/0016delete_handle_0 | 36 ++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100755 tests/shell/testcases/chains/0016delete_handle_0
tests/shell/testcases/chains/0016delete_handle_0 new file +36 -0
new file mode 100755
index 0000000..cf11da8
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+set -e
+$NFT add table test-ip
+$NFT add chain test-ip x	# should have handle 1
+$NFT add chain test-ip y	# should have handle 2
+$NFT add chain test-ip z	# should have handle 3
+$NFT add table ip6 test-ip6
+$NFT add chain ip6 test-ip6 x	# should have handle 1
+$NFT add chain ip6 test-ip6 y	# should have handle 2
+$NFT add chain ip6 test-ip6 z	# should have handle 3
+$NFT delete chain test-ip handle 2
+$NFT delete chain ip6 test-ip6 handle 3
+
+EXPECTED="table ip test-ip {
+	chain x {
+	}
+
+	chain z {
+	}
+}
+table ip6 test-ip6 {
+	chain x {
+	}
+
+	chain y {
+	}
+}"
+
+GET="$($NFT list ruleset)"
+
+if [ "$EXPECTED" != "$GET" ] ; then
+	DIFF="$(which diff)"
+	[ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+	exit 1
+fi
Signature · 1 line
2.11.0