]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/pfctl/tests/pfctl_test.sh
MFV r346563:
[FreeBSD/FreeBSD.git] / sbin / pfctl / tests / pfctl_test.sh
1 # $FreeBSD$
2 # Make will add a #! line at the top of this file.
3
4 # Tests 0001-0999 are copied from OpenBSD's regress/sbin/pfctl.
5 # Tests 1001-1999 are ours (FreeBSD's own).
6
7 # pf: Run pfctl -nv on pfNNNN.in and check that the output matches pfNNNN.ok.
8 #     Copied from OpenBSD.  Main differences are some things not working
9 #     in FreeBSD:
10 #         * The action 'match'
11 #         * The command 'set reassemble'
12 #         * The 'from'/'to' options together with 'route-to'
13 #         * The option 'scrub' (it is an action in FreeBSD)
14 #         * Accepting undefined routing tables in actions (??: see pf0093.in)
15 #         * The 'route' option
16 #         * The 'set queue def' option
17 # selfpf: Feed pfctl output through pfctl again and verify it stays the same.
18 #         Copied from OpenBSD.
19
20 pftests="0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012
21 0013 0014 0016 0018 0019 0020 0022 0023 0024 0025 0026 0028 0030 0031
22 0032 0034 0035 0038 0039 0040 0041 0047 0048 0049 0050 0052 0053 0055
23 0056 0057 0060 0061 0065 0067 0069 0070 0071 0072 0074 0075 0077 0078
24 0079 0081 0082 0084 0085 0087 0088 0089 0090 0091 0092 0094 0095 0096
25 0097 0098 0100 0101 0102 0104 1001 1002 1003 1004 1005"
26
27 . $(atf_get_srcdir)/files/pfctl_test_descr.sh
28
29 for i in ${pftests} ; do
30     atf_test_case "pf${i}"
31     eval "pf${i}_head () { atf_set descr \"$(pf${i}_descr)\" ; }"
32     eval "pf${i}_body () { \
33               kldstat -m pf || atf_skip \"pf(4) is not loaded\" && \
34               cd $(atf_get_srcdir)/files && \
35               atf_check -o file:pf${i}.ok \
36                   pfctl -o none -nvf - < pf${i}.in ; }"
37
38     atf_test_case "selfpf${i}"
39     eval "selfpf${i}_head () { atf_set descr \"self$(pf${i}_descr)\" ; }"
40     eval "selfpf${i}_body () { \
41               cd $(atf_get_srcdir)/files && \
42               atf_check -o file:pf${i}.ok \
43                   pfctl -o none -nvf - < pf${i}.ok ; }"
44 done
45
46 atf_init_test_cases () {
47     for i in ${pftests} ; do atf_add_test_case "pf${i}"
48                              atf_add_test_case "selfpf${i}" ; done ; }