]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: testcase for adding many set elements
authorArturo Borrero Gonzalez <arturo@debian.org>
Wed, 16 Nov 2016 12:53:15 +0000 (13:53 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Nov 2016 12:01:16 +0000 (13:01 +0100)
This testcase adds many elements in a set.
We add 65.356 elements.

Signed-off-by: Arturo Borrero Gonzalez <arturo@debian.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/sets/0011add_many_elements_0 [new file with mode: 0755]

diff --git a/tests/shell/testcases/sets/0011add_many_elements_0 b/tests/shell/testcases/sets/0011add_many_elements_0
new file mode 100755 (executable)
index 0000000..ba23f90
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# test adding many sets elements
+
+HOWMANY=255
+
+tmpfile=$(mktemp)
+if [ ! -w $tmpfile ] ; then
+       echo "Failed to create tmp file" >&2
+       exit 0
+fi
+
+trap "rm -rf $tmpfile" EXIT # cleanup if aborted
+
+generate() {
+       echo -n "{"
+       for ((i=1; i<=HOWMANY; i++)) ; do
+               for ((j=1; j<=HOWMANY; j++)) ; do
+                       echo -n "10.0.${i}.${j}"
+                       [ "$i" == "$HOWMANY" ] && [ "$j" == "$HOWMANY" ] && break
+                       echo -n ", "
+               done
+       done
+       echo -n "}"
+}
+
+echo "add table x
+add set x y { type ipv4_addr; }
+add element x y $(generate)" > $tmpfile
+
+set -e
+$NFT -f $tmpfile