summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/sets/automerge_0
blob: c9fb609571fa8e74c51e949f797a8ed433222cab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash

set -e

RULESET="table inet x {
	set y {
		type inet_service
		flags interval
		auto-merge
	}
}"

$NFT -f - <<< $RULESET

tmpfile=$(mktemp)
echo -n "add element inet x y { " > $tmpfile
for ((i=0;i<65535;i+=2))
do
	echo -n "$i, " >> $tmpfile
	if [ $i -eq 65534 ]
	then
		echo -n "$i" >> $tmpfile
	fi
done
echo "}" >> $tmpfile

$NFT -f $tmpfile

tmpfile2=$(mktemp)
for ((i=1;i<65535;i+=2))
do
	echo "$i" >> $tmpfile2
done

tmpfile3=$(mktemp)
shuf $tmpfile2 > $tmpfile3
i=0
cat $tmpfile3 | while read line && [ $i -lt 10 ]
do
	$NFT add element inet x y { $line }
	i=$((i+1))
done

for ((i=0;i<10;i++))
do
	from=$(($RANDOM%65535))
	to=$(($from+100))
	$NFT add element inet x y { $from-$to }
	if [ $? -ne 0 ]
	then
		echo "failed to add $from-$to"
		exit 1
	fi
	$NFT get element inet x y { $from-$to }
	if [ $? -ne 0 ]
	then
		echo "failed to get $from-$to"
		exit 1
	fi
done

rm -f $tmpfile
rm -f $tmpfile2
rm -f $tmpfile3