diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 3882db287f5a..5a8b5fe8de70 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -1,49 +1,50 @@ # $FreeBSD$ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/netpfil/pf TESTS_SUBDIRS+= ioctl ATF_TESTS_SH+= altq \ anchor \ pass_block \ checksum \ forward \ fragmentation \ get_state \ icmp \ killstate \ + macro \ map_e \ names \ nat \ rules_counter \ set_tos \ src_track \ rdr \ route_to \ syncookie \ synproxy \ set_skip \ pfsync \ proxy \ table \ tos ${PACKAGE}FILES+= utils.subr \ echo_inetd.conf \ CVE-2019-5597.py \ CVE-2019-5598.py \ fragcommon.py \ frag-overindex.py \ frag-overlimit.py \ frag-overreplace.py ${PACKAGE}FILESMODE_CVE-2019-5597.py= 0555 ${PACKAGE}FILESMODE_CVE-2019-5598.py= 0555 ${PACKAGE}FILESMODE_fragcommon.py= 0555 ${PACKAGE}FILESMODE_frag-overindex.py= 0555 ${PACKAGE}FILESMODE_frag-overlimit.py= 0555 ${PACKAGE}FILESMODE_frag-overreplace.py= 0555 .include diff --git a/tests/sys/netpfil/pf/macro.sh b/tests/sys/netpfil/pf/macro.sh new file mode 100644 index 000000000000..442677c9f946 --- /dev/null +++ b/tests/sys/netpfil/pf/macro.sh @@ -0,0 +1,40 @@ +. $(atf_get_srcdir)/utils.subr + +atf_test_case "nr" "cleanup" +nr_head() +{ + atf_set descr 'Test $nr expansion' + atf_set require.user root +} + +nr_body() +{ + # Ensure that when the optimiser collapses rules the macro expansion + # has the correct rule number + pft_init + + vnet_mkjail alcatraz + jexec alcatraz ifconfig lo0 inet 127.0.0.1/8 + jexec alcatraz ifconfig lo0 inet 127.0.0.2/32 alias + + pft_set_rules alcatraz \ + "pass quick on lo from lo:network to lo:network" \ + "block quick all label \"ruleNo:\$nr\"" + + no=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub("@", "", $1); print $1; }') + ruleno=$(jexec alcatraz pfctl -sr -vv | awk '/ruleNo/ { gsub(/"ruleNo:/, "", $7); gsub(/"/, "", $7); print $7; }') + if [ "${no}" -ne "${ruleno}" ]; + then + atf_fail "Expected ruleNo $no != $ruleno" + fi +} + +nr_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "nr" +}