Debian Codegraph @

tests/shell/testcases/sets/0036add_set_element_expiration_0

raw
1 #!/bin/bash
2
3 # NFT_TEST_REQUIRES(NFT_TEST_HAVE_setelem_expiration)
4
5 set -e
6
7 drop_seconds() {
8 sed -E 's/m[0-9]*s([0-9]*ms)?/m/g'
9 }
10
11 RULESET="add table ip x
12 add set ip x y { type ipv4_addr; flags dynamic,timeout; }
13 add element ip x y { 1.1.1.1 timeout 30m expires 15m59s }"
14
15 EXPECTED="add table ip x
16 add set ip x y { type ipv4_addr; flags dynamic,timeout; }
17 add element ip x y { 1.1.1.1 timeout 30m expires 15m }"
18
19 test_output=$($NFT -e -f - <<< "$RULESET" 2>&1 | grep -v '# new generation' | drop_seconds)
20
21 if [ "$test_output" != "$EXPECTED" ] ; then
22 $DIFF -u <(echo "$test_output") <(echo "$EXPECTED")
23 exit 1
24 fi
25
26 $NFT "add chain ip x c; add rule ip x c ip saddr @y"