Debian Codegraph @

tests/shell/testcases/sets/0030add_many_elements_interval_0

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