Debian Codegraph @

tests/shell/testcases/sets/0011add_many_elements_0

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