From e5590a688fd1d46f1722afe6aec3b7c74fd6d883 Mon Sep 17 00:00:00 2001 From: Arturo Borrero Date: Fri, 11 Dec 2015 11:10:35 +0100 Subject: tests/shell: add test case for cache bug 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 Signed-off-by: Pablo Neira Ayuso --- tests/shell/testcases/sets/cache_handling_0 | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 tests/shell/testcases/sets/cache_handling_0 (limited to 'tests/shell') diff --git a/tests/shell/testcases/sets/cache_handling_0 b/tests/shell/testcases/sets/cache_handling_0 new file mode 100755 index 00000000..c79e0139 --- /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 -- cgit v1.2.3