]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: add test case for cache bug
authorArturo Borrero <arturo.borrero.glez@gmail.com>
Fri, 11 Dec 2015 10:10:35 +0000 (11:10 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 18 Dec 2015 12:59:41 +0000 (13:59 +0100)
This testcase for sets catch a cache bug.

By the time of this commit this test is failing, so the test suite shows:

% sudo ./run-tests.sh
I: using nft binary /usr/local/sbin/nft

I: [OK] ./testcases/maps/anonymous_snat_map_0
I: [OK] ./testcases/maps/named_snat_map_0
W: [FAILED] ./testcases/sets/cache_handling_0
I: [OK] ./testcases/optionals/comments_0
I: [OK] ./testcases/optionals/comments_handles_monitor_0
I: [OK] ./testcases/optionals/handles_1
I: [OK] ./testcases/optionals/handles_0
I: [OK] ./testcases/optionals/comments_handles_0

I: results: [OK] 7 [FAILED] 1 [TOTAL] 8

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

diff --git a/tests/shell/testcases/sets/cache_handling_0 b/tests/shell/testcases/sets/cache_handling_0
new file mode 100755 (executable)
index 0000000..c79e013
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+MKTEMP=$(which mktemp)
+if [ -x $MKTEMP ] ; then
+       tmpfile=$(${MKTEMP})
+else
+       tmpfile=$(/tmp/${RANDOM})
+fi
+
+if [ ! -w $tmpfile ] ; then
+       echo "Failed to create tmp file" >&2
+       exit 0
+fi
+
+trap "rm -rf $tmpfile" EXIT # cleanup if aborted
+
+echo "
+table inet test {
+       set test {
+               type ipv4_addr
+               elements = { 1.1.1.1}
+       }
+
+       chain test {
+               ip saddr @test counter accept
+               ip daddr { 2.2.2.2} counter accept
+       }
+}" > $tmpfile
+
+set -e
+
+$NFT -f $tmpfile
+$NFT delete rule inet test test handle 2
+$NFT delete set inet test test
+$NFT -f $tmpfile