]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: inline input data in "single_anon_set" test
authorThomas Haller <thaller@redhat.com>
Mon, 23 Oct 2023 16:13:15 +0000 (18:13 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 24 Oct 2023 09:31:02 +0000 (11:31 +0200)
The file "optimizations/dumps/single_anon_set.nft.input" was laying
around, and it was unclear how it was used.

Let's extend "check-patch.sh" to flag all unused files. But the script
cannot understand how "single_anon_set.nft.input" is used (aside allow
listing it).

Instead, inline the script to keep it inside the test (script).

We still write the data to a separate file and don't use `nft -f -`
(because reading stdin uses a different code path we want to cover).

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/optimizations/dumps/single_anon_set.nft.input [deleted file]
tests/shell/testcases/optimizations/single_anon_set

diff --git a/tests/shell/testcases/optimizations/dumps/single_anon_set.nft.input b/tests/shell/testcases/optimizations/dumps/single_anon_set.nft.input
deleted file mode 100644 (file)
index ecc5691..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-table ip test {
-       chain test {
-               # Test cases where anon set can be removed:
-               ip saddr { 127.0.0.1 } accept
-               iif { "lo" } accept
-
-               # negation, can change to != 22.
-               tcp dport != { 22 } drop
-
-               # single prefix, can remove anon set.
-               ip saddr { 127.0.0.0/8 } accept
-
-               # range, can remove anon set.
-               ip saddr { 127.0.0.1-192.168.7.3 } accept
-               tcp sport { 1-1023 } drop
-
-               # Test cases where anon set must be kept.
-
-               # 2 elements, cannot remove the anon set.
-               ip daddr { 192.168.7.1, 192.168.7.5 } accept
-               tcp dport { 80, 443 } accept
-
-               # single element, but concatenation which is not
-               # supported outside of set/map context at this time.
-               ip daddr . tcp dport { 192.168.0.1 . 22 } accept
-
-               # single element, but a map.
-               meta mark set ip daddr map { 192.168.0.1 : 1 }
-
-               # 2 elements.  This could be converted because
-               # ct state cannot be both established and related
-               # at the same time, but this needs extra work.
-               ct state { established, related } accept
-
-               # with stateful statement
-               meta mark { 0x0000000a counter }
-       }
-}
index 7275e3606900c6c4bd63bacd9c547b0a6b634c3a..84fc2a7f03a88d3440bbe300a8158179c211efb2 100755 (executable)
@@ -2,12 +2,55 @@
 
 set -e
 
+test -d "$NFT_TEST_TESTTMPDIR"
+
 # Input file contains rules with anon sets that contain
 # one element, plus extra rule with two elements (that should be
 # left alone).
 
 # Dump file has the simplified rules where anon sets have been
 # replaced by equality tests where possible.
-dumpfile=$(dirname $0)/dumps/$(basename $0).nft
+file_input1="$NFT_TEST_TESTTMPDIR/input1.nft"
+
+cat <<EOF > "$file_input1"
+table ip test {
+       chain test {
+               # Test cases where anon set can be removed:
+               ip saddr { 127.0.0.1 } accept
+               iif { "lo" } accept
+
+               # negation, can change to != 22.
+               tcp dport != { 22 } drop
+
+               # single prefix, can remove anon set.
+               ip saddr { 127.0.0.0/8 } accept
+
+               # range, can remove anon set.
+               ip saddr { 127.0.0.1-192.168.7.3 } accept
+               tcp sport { 1-1023 } drop
+
+               # Test cases where anon set must be kept.
+
+               # 2 elements, cannot remove the anon set.
+               ip daddr { 192.168.7.1, 192.168.7.5 } accept
+               tcp dport { 80, 443 } accept
+
+               # single element, but concatenation which is not
+               # supported outside of set/map context at this time.
+               ip daddr . tcp dport { 192.168.0.1 . 22 } accept
+
+               # single element, but a map.
+               meta mark set ip daddr map { 192.168.0.1 : 1 }
+
+               # 2 elements.  This could be converted because
+               # ct state cannot be both established and related
+               # at the same time, but this needs extra work.
+               ct state { established, related } accept
+
+               # with stateful statement
+               meta mark { 0x0000000a counter }
+       }
+}
+EOF
 
-$NFT -f "$dumpfile".input
+$NFT -f "$file_input1"