summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2017-01-24 19:33:07 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2017-01-24 19:34:48 +0100
commitc875374f4c846fddf22026db479e73e6ddb3b5b3 (patch)
tree4ae51e19e9dd0a80bf797d8019c8cd50a97d513a /tests
parent5c33d714b433a575aa40754da563842db7f1e774 (diff)
tests: shell: validate set size
Add two tests to make sure that set size checks work fine: 1) Check if set size is indeed working, this is a simple one. 2) Check if set size is correct after ENFILE error, there is bug that adds a new spare slot everytime we hit this. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/shell/testcases/sets/0018set_check_size_18
-rwxr-xr-xtests/shell/testcases/sets/0019set_check_size_020
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/shell/testcases/sets/0018set_check_size_1 b/tests/shell/testcases/sets/0018set_check_size_1
new file mode 100755
index 00000000..833b8e2b
--- /dev/null
+++ b/tests/shell/testcases/sets/0018set_check_size_1
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -e
+$NFT add table x
+$NFT add set x s {type ipv4_addr\; size 2\;}
+$NFT add element x s {1.1.1.1}
+$NFT add element x s {1.1.1.2}
+$NFT add element x s {1.1.1.3}
diff --git a/tests/shell/testcases/sets/0019set_check_size_0 b/tests/shell/testcases/sets/0019set_check_size_0
new file mode 100755
index 00000000..c2097083
--- /dev/null
+++ b/tests/shell/testcases/sets/0019set_check_size_0
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+$NFT add table x
+$NFT add set x s {type ipv4_addr\; size 2\;}
+$NFT add element x s {1.1.1.1}
+$NFT add element x s {1.1.1.2}
+
+$NFT add element x s { 1.1.1.3 } 2>/dev/null
+if [ $? -eq 0 ]; then
+ echo "E: set is full, but element was added" >&2
+ exit 1
+fi
+#
+# Try again, this helps us catch incorrect set->nelems decrement from abort path
+#
+$NFT add element x s { 1.1.1.3 } 2>/dev/null
+if [ $? -eq 0 ]; then
+ echo "E: set is full, but element was added" >&2
+ exit 1
+fi