]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: add tests for handles and comments
authorArturo Borrero <arturo.borrero.glez@gmail.com>
Wed, 23 Dec 2015 13:19:22 +0000 (14:19 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 25 Dec 2015 12:16:37 +0000 (13:16 +0100)
Here some tests for optional things like rule handles and comments.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/optionals/comments_0 [new file with mode: 0755]
tests/shell/testcases/optionals/comments_handles_0 [new file with mode: 0755]
tests/shell/testcases/optionals/handles_0 [new file with mode: 0755]
tests/shell/testcases/optionals/handles_1 [new file with mode: 0755]

diff --git a/tests/shell/testcases/optionals/comments_0 b/tests/shell/testcases/optionals/comments_0
new file mode 100755 (executable)
index 0000000..29b8506
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# comments are shown
+
+$NFT add table test
+$NFT add chain test test
+$NFT add rule test test tcp dport 22 counter accept comment test_comment
+$NFT list table test -a | grep 'accept comment \"test_comment\"' >/dev/null
diff --git a/tests/shell/testcases/optionals/comments_handles_0 b/tests/shell/testcases/optionals/comments_handles_0
new file mode 100755 (executable)
index 0000000..30539bf
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# handles and comments mix well
+
+$NFT add table test
+$NFT add chain test test
+$NFT add rule test test tcp dport 22 counter accept comment test_comment
+set -e
+$NFT list table test -a | grep 'accept comment \"test_comment\" # handle '[[:digit:]]$ >/dev/null
+$NFT list table test | grep 'accept comment \"test_comment\"' | grep -v '# handle '[[:digit:]]$ >/dev/null
diff --git a/tests/shell/testcases/optionals/handles_0 b/tests/shell/testcases/optionals/handles_0
new file mode 100755 (executable)
index 0000000..7c6a437
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# handles are shown last
+
+$NFT add table test
+$NFT add chain test test
+$NFT add rule test test tcp dport 22 counter accept
+$NFT list table test -a | grep 'accept # handle '[[:digit:]]$ >/dev/null
diff --git a/tests/shell/testcases/optionals/handles_1 b/tests/shell/testcases/optionals/handles_1
new file mode 100755 (executable)
index 0000000..a3ae1a7
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# handles are not shown if not asked for them
+
+$NFT add table test
+$NFT add chain test test
+$NFT add rule test test tcp dport 22 counter accept
+$NFT list table test | grep 'accept # handle '[[:digit:]]$ >/dev/null