summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/chains
diff options
context:
space:
mode:
authorHarsha Sharma <harshasharmaiitr@gmail.com>2018-01-15 01:03:07 +0530
committerPablo Neira Ayuso <pablo@netfilter.org>2018-03-05 16:41:07 +0100
commit226aee27c209f52ea947473f5b4b9980596e2fc6 (patch)
tree0cf8c02ad5996e013ba6ad91d2c49152401a56b6 /tests/shell/testcases/chains
parentf4a34d25f6d5f4188573dbe16613ce96327f0e6c (diff)
tests/shell: add tests for deletion of chains via chain handle
Delete chain with given unique handle for a table. Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/shell/testcases/chains')
-rwxr-xr-xtests/shell/testcases/chains/0016delete_handle_036
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/shell/testcases/chains/0016delete_handle_0 b/tests/shell/testcases/chains/0016delete_handle_0
new file mode 100755
index 00000000..cf11da8a
--- /dev/null
+++ b/tests/shell/testcases/chains/0016delete_handle_0
@@ -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