summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/sets/0028delete_handle_0
blob: 5ad17c223db27c7323c0cca5a491fd7ea372cbd4 (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
#!/bin/bash

set -e
$NFT add table test-ip
$NFT add set test-ip x { type ipv4_addr\; }
$NFT add set test-ip y { type inet_service \; timeout 3h45s \;}
$NFT add set test-ip z { type ipv4_addr\; flags constant , interval\;}
$NFT add set test-ip c {type ipv4_addr \; flags timeout \; elements={192.168.1.1 timeout 10s, 192.168.1.2 timeout 30s} \;}

set_handle=$($NFT -a list ruleset | awk '/set c/{print $NF}')
$NFT delete set test-ip handle $set_handle

EXPECTED="table ip test-ip {
	set x {
		type ipv4_addr
	}

	set y {
		type inet_service
		timeout 3h45s
	}

	set z {
		type ipv4_addr
		flags constant,interval
	}
}"

GET="$($NFT list ruleset)"

if [ "$EXPECTED" != "$GET" ] ; then
	DIFF="$(which diff)"
	[ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
	exit 1
fi