diff mbox

[5/5] tests/shell: add test case for cache bug

Message ID 144982863572.31246.7502516560404421735.stgit@r2d2.cica.es
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Arturo Borrero Dec. 11, 2015, 10:10 a.m. UTC
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>
---
 tests/shell/testcases/sets/cache_handling_0 |   35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100755 tests/shell/testcases/sets/cache_handling_0


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tests/shell/testcases/sets/cache_handling_0 b/tests/shell/testcases/sets/cache_handling_0
new file mode 100755
index 0000000..c79e013
--- /dev/null
+++ b/tests/shell/testcases/sets/cache_handling_0
@@ -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