netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Harsha Sharma <harshasharmaiitr@gmail.com>
To: pablo@netfilter.org, harshasharmaiitr@gmail.com
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH] tests/shell: add tests for deletion of chains via chain handle
Date: Mon, 15 Jan 2018 01:03:07 +0530	[thread overview]
Message-ID: <20180114193307.7374-1-harshasharmaiitr@gmail.com> (raw)

Delete chain with given unique handle for a table.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
 tests/shell/testcases/chains/0016delete_handle_0 | 36 ++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100755 tests/shell/testcases/chains/0016delete_handle_0

diff --git a/tests/shell/testcases/chains/0016delete_handle_0 b/tests/shell/testcases/chains/0016delete_handle_0
new file mode 100755
index 0000000..cf11da8
--- /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
-- 
2.11.0


                 reply	other threads:[~2018-01-14 19:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180114193307.7374-1-harshasharmaiitr@gmail.com \
    --to=harshasharmaiitr@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).