Debian Codegraph @

tests/shell/testcases/sets/0013add_delete_many_elements_0

raw
1 #!/bin/bash
2
3 # test adding and deleting many sets elements in two nft -f runs.
4
5 HOWMANY=255
6 if [ "$NFT_TEST_HAS_SOCKET_LIMITS" = y ] ; then
7 # The socket limit /proc/sys/net/core/wmem_max may be unsuitable for
8 # the test.
9 #
10 # Run only a subset of the test and mark as skipped at the end.
11 HOWMANY=30
12 fi
13
14 tmpfile=$(mktemp)
15 if [ ! -w $tmpfile ] ; then
16 echo "Failed to create tmp file" >&2
17 exit 0
18 fi
19
20 trap "rm -rf $tmpfile" EXIT # cleanup if aborted
21
22 generate() {
23 echo -n "{"
24 for ((i=1; i<=HOWMANY; i++)) ; do
25 for ((j=1; j<=HOWMANY; j++)) ; do
26 echo -n "10.0.${i}.${j}"
27 [ "$i" == "$HOWMANY" ] && [ "$j" == "$HOWMANY" ] && break
28 echo -n ", "
29 done
30 done
31 echo -n "}"
32 }
33
34 set -e
35
36 echo "add table x
37 add set x y { type ipv4_addr; }
38 add element x y $(generate)" > $tmpfile
39 $NFT -f $tmpfile
40 echo "delete element x y $(generate)" > $tmpfile
41 $NFT -f $tmpfile
42
43 if [ "$HOWMANY" != 255 ] ; then
44 echo "NFT_TEST_HAS_SOCKET_LIMITS indicates that the socket limit for"
45 echo "/proc/sys/net/core/wmem_max is too small for this test. Mark as SKIPPED"
46 echo "You may bump the limit and rerun with \`NFT_TEST_HAS_SOCKET_LIMITS=n\`."
47 exit 77
48 fi