1# $NetBSD: t_filter_exec.sh,v 1.8 2013/03/17 03:00:05 jmmv Exp $ 2# 3# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25# POSSIBILITY OF SUCH DAMAGE. 26# 27# 28# (C)opyright 1993-1996 by Darren Reed. 29# 30# See the IPFILTER.LICENCE file for details on licencing. 31# 32 33dotest() 34{ 35 h_copydata $1 36 infmt=$2 37 outfmt=$3 38 shift 39 shift 40 shift 41 args=$@ 42 43 if [ $outfmt = hex ] ; then 44 output=-x 45 else 46 output= 47 fi 48 49 { while read rule; do 50 atf_check -x "echo \"$rule\" | ipftest -F \ 51$infmt $output -Rbr - -i in $args >>out" 52 echo "--------" >>out 53 done; } <reg 54 55 diff -u exp out || atf_fail "results differ" 56} 57 58mtest() 59{ 60 h_copydata $1 61 infmt=$2 62 outfmt=$3 63 shift 64 shift 65 shift 66 args=$@ 67 68 if [ $outfmt = hex ] ; then 69 output=-x 70 else 71 output= 72 fi 73 74 75 atf_check -o save:out ipftest -F $infmt $output -Rbr reg -i in $args 76 echo "--------" >>out 77 78 diff -u exp out || atf_fail "results differ" 79} 80 81dotest6() 82{ 83 h_copydata $(echo ${1} | tr _ .) 84 infmt=$2 85 outfmt=$3 86 shift 87 shift 88 shift 89 args=$@ 90 91 if [ $outfmt = hex ] ; then 92 output=-x 93 else 94 output= 95 fi 96 97 98 ipftest -6 -r /dev/null -i /dev/null >/dev/null 2>&1 \ 99 || atf_skip "skipping IPv6 tests" 100 101 { while read rule; do 102 atf_check -o save:save -x "echo \"$rule\" | \ 103ipftest -F $infmt $output -6br - -i in $args" 104 cat save >>out 105 echo "--------" >>out 106 done; } <reg 107 108 diff -u exp out || atf_fail "results differ" 109} 110 111test_case f1 dotest text text 112test_case f2 dotest text text 113test_case f3 dotest text text 114test_case f4 dotest text text 115test_case f5 dotest text text 116test_case f6 dotest text text 117test_case f7 dotest text text 118test_case f8 dotest text text 119test_case f9 dotest text text 120test_case f10 dotest text text 121test_case f11 dotest text text -D 122test_case f12 dotest hex hex 123test_case f13 dotest hex hex 124test_case f14 dotest text text 125test_case f15 mtest text text 126test_case f16 mtest text text 127test_case f17 mtest hex hex 128test_case f18 mtest text text -D 129test_case f19 dotest text text -T state_max=3 130test_case f20 mtest text text 131test_case f24 mtest hex text 132test_case f25 mtest hex text -D 133failing_test_case f26 dotest "Known to be broken" text text 134failing_test_case f27 dotest "Known to be broken" hex text 135test_case f30 dotest text text 136test_case ipv6_1 dotest6 hex hex 137test_case ipv6_2 dotest6 hex hex 138test_case ipv6_3 dotest6 hex hex 139test_case ipv6_5 dotest6 hex hex 140test_case ipv6_6 dotest6 hex text 141 142atf_init_test_cases() 143{ 144 atf_add_test_case f1 145 atf_add_test_case f2 146 atf_add_test_case f3 147 atf_add_test_case f4 148 atf_add_test_case f5 149 atf_add_test_case f6 150 atf_add_test_case f7 151 atf_add_test_case f8 152 atf_add_test_case f9 153 atf_add_test_case f10 154 atf_add_test_case f11 155 atf_add_test_case f12 156 atf_add_test_case f13 157 atf_add_test_case f14 158 atf_add_test_case f15 159 atf_add_test_case f16 160 atf_add_test_case f17 161 atf_add_test_case f18 162 atf_add_test_case f19 163 atf_add_test_case f20 164 atf_add_test_case f24 165 atf_add_test_case f25 166 atf_add_test_case f26 167 atf_add_test_case f27 168 atf_add_test_case f30 169 atf_add_test_case ipv6_1 170 atf_add_test_case ipv6_2 171 atf_add_test_case ipv6_3 172 atf_add_test_case ipv6_5 173 atf_add_test_case ipv6_6 174 175} 176