Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/netpfil/pf/macro.sh
39507 views
1
. $(atf_get_srcdir)/utils.subr
2
3
atf_test_case "nr" "cleanup"
4
nr_head()
5
{
6
atf_set descr 'Test $nr expansion'
7
atf_set require.user root
8
}
9
10
nr_body()
11
{
12
# Ensure that when the optimiser collapses rules the macro expansion
13
# has the correct rule number
14
pft_init
15
16
vnet_mkjail alcatraz
17
jexec alcatraz ifconfig lo0 inet 127.0.0.1/8
18
jexec alcatraz ifconfig lo0 inet 127.0.0.2/32 alias
19
20
pft_set_rules alcatraz \
21
"pass quick on lo from lo:network to lo:network" \
22
"block quick all label \"ruleNo:\$nr\""
23
24
no=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub("@", "", $1); print $1; }')
25
ruleno=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub(/"ruleNo:/, "", $7); gsub(/"/, "", $7); print $7; }')
26
if [ "${no}" -ne "${ruleno}" ];
27
then
28
atf_fail "Expected ruleNo $no != $ruleno"
29
fi
30
}
31
32
nr_cleanup()
33
{
34
pft_cleanup
35
}
36
37
atf_init_test_cases()
38
{
39
atf_add_test_case "nr"
40
}
41
42