]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: add a few tests for nft -i
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 15 Aug 2024 10:25:36 +0000 (12:25 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 19 Aug 2024 15:24:31 +0000 (17:24 +0200)
Eric Garver recently provided a few tests for nft -i that helped
identify issues that resulted in reverting:

  e791dbe109b6 ("cache: recycle existing cache with incremental updates")

add these tests to tests/shell.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/nft-i/dumps/index_0.nft [new file with mode: 0644]
tests/shell/testcases/nft-i/dumps/set_0.nft [new file with mode: 0644]
tests/shell/testcases/nft-i/index_0 [new file with mode: 0755]
tests/shell/testcases/nft-i/set_0 [new file with mode: 0755]

diff --git a/tests/shell/testcases/nft-i/dumps/index_0.nft b/tests/shell/testcases/nft-i/dumps/index_0.nft
new file mode 100644 (file)
index 0000000..abcd1b7
--- /dev/null
@@ -0,0 +1,8 @@
+table inet foo {
+       chain bar {
+               type filter hook input priority filter; policy accept;
+               accept
+               accept
+               accept
+       }
+}
diff --git a/tests/shell/testcases/nft-i/dumps/set_0.nft b/tests/shell/testcases/nft-i/dumps/set_0.nft
new file mode 100644 (file)
index 0000000..d3377d6
--- /dev/null
@@ -0,0 +1,7 @@
+table inet foo {
+       set bar {
+               type ipv4_addr
+               flags interval
+               elements = { 10.1.1.1, 10.1.1.2 }
+       }
+}
diff --git a/tests/shell/testcases/nft-i/index_0 b/tests/shell/testcases/nft-i/index_0
new file mode 100755 (executable)
index 0000000..f885fde
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="add table inet foo
+add chain inet foo bar { type filter hook input priority filter; }
+add rule inet foo bar accept
+insert rule inet foo bar index 0 accept
+add rule inet foo bar index 0 accept"
+
+$NFT -i <<< "$RULESET"
diff --git a/tests/shell/testcases/nft-i/set_0 b/tests/shell/testcases/nft-i/set_0
new file mode 100755 (executable)
index 0000000..e87eef1
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+
+RULESET="add table inet foo
+add set inet foo bar { type ipv4_addr; flags interval; }; add element inet foo bar { 10.1.1.1/32 }
+add element inet foo bar { 10.1.1.2/32 }"
+
+$NFT -i <<< "$RULESET"