t_npf.sh revision 1.1
11.1Smartin# $NetBSD: t_npf.sh,v 1.1 2012/09/12 14:06:31 martin Exp $
21.1Smartin#
31.1Smartin# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
41.1Smartin# All rights reserved.
51.1Smartin#
61.1Smartin# Redistribution and use in source and binary forms, with or without
71.1Smartin# modification, are permitted provided that the following conditions
81.1Smartin# are met:
91.1Smartin# 1. Redistributions of source code must retain the above copyright
101.1Smartin#    notice, this list of conditions and the following disclaimer.
111.1Smartin# 2. Redistributions in binary form must reproduce the above copyright
121.1Smartin#    notice, this list of conditions and the following disclaimer in the
131.1Smartin#    documentation and/or other materials provided with the distribution.
141.1Smartin#
151.1Smartin# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
161.1Smartin# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
171.1Smartin# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
181.1Smartin# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
191.1Smartin# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
201.1Smartin# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
211.1Smartin# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
221.1Smartin# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
231.1Smartin# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
241.1Smartin# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
251.1Smartin# POSSIBILITY OF SUCH DAMAGE.
261.1Smartin#
271.1Smartin
281.1Smartinrun_test()
291.1Smartin{
301.1Smartin	local name="${1}"
311.1Smartin
321.1Smartin	atf_check -o ignore -e ignore npfctl debug "$(atf_get_srcdir)/npftest.conf" ./npf.plist
331.1Smartin	atf_check -o ignore npftest -c npf.plist -T "${name}"
341.1Smartin}
351.1Smartin
361.1Smartinadd_test()
371.1Smartin{
381.1Smartin	local name="${1}"; shift
391.1Smartin	local desc="${*}";
401.1Smartin
411.1Smartin	atf_test_case "npf_${name}"
421.1Smartin	eval "npf_${name}_head() { \
431.1Smartin			atf_set \"descr\" \"${desc}\"; \
441.1Smartin		}; \
451.1Smartin	    npf_${name}_body() { \
461.1Smartin			run_test \"${name}\"; \
471.1Smartin		}"
481.1Smartin	atf_add_test_case "npf_${name}"
491.1Smartin}
501.1Smartin
511.1Smartinatf_init_test_cases()
521.1Smartin{
531.1Smartin	LIST=/tmp/t_npf.$$
541.1Smartin	trap "rm -f $LIST" EXIT
551.1Smartin
561.1Smartin	npftest -L > $LIST
571.1Smartin
581.1Smartin	while read tag desc
591.1Smartin	do
601.1Smartin		add_test "${tag}" "${desc}"
611.1Smartin	done < $LIST
621.1Smartin}
63