11.9Sjoe# $NetBSD: t_npf.sh,v 1.9 2025/07/20 12:25:54 joe 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.9Sjoe if [ "$name" = "l2defpass" ]; then 331.9Sjoe atf_check -o ignore -e ignore npfctl debug -c "$(atf_get_srcdir)/npftestl3.conf" -o ./npf.plist 341.9Sjoe else 351.9Sjoe atf_check -o ignore -e ignore npfctl debug -c "$(atf_get_srcdir)/npftest.conf" -o ./npf.plist 361.9Sjoe fi 371.9Sjoe 381.1Smartin atf_check -o ignore npftest -c npf.plist -T "${name}" 391.1Smartin} 401.1Smartin 411.8Sriastradcleanup() 421.8Sriastrad{ 431.8Sriastrad 441.8Sriastrad if [ -f npftest.core ]; then 451.8Sriastrad gdb -batch -ex bt npftest npftest.core 461.8Sriastrad # Extract kernel logs including a panic message 471.8Sriastrad strings npftest.core |grep -E '^\[.+\] ' 481.8Sriastrad fi 491.8Sriastrad} 501.8Sriastrad 511.1Smartinadd_test() 521.1Smartin{ 531.1Smartin local name="${1}"; shift 541.1Smartin local desc="${*}"; 551.1Smartin 561.8Sriastrad atf_test_case "npf_${name}" cleanup 571.3Sozaki eval "npf_${name}_head() { 581.3Sozaki atf_set descr \"${desc}\" 591.3Sozaki atf_set require.progs npfctl npftest 601.3Sozaki } 611.3Sozaki npf_${name}_body() { 621.3Sozaki run_test ${name} 631.8Sriastrad } 641.8Sriastrad npf_${name}_cleanup() { 651.8Sriastrad cleanup 661.1Smartin }" 671.1Smartin atf_add_test_case "npf_${name}" 681.1Smartin} 691.1Smartin 701.1Smartinatf_init_test_cases() 711.1Smartin{ 721.1Smartin LIST=/tmp/t_npf.$$ 731.1Smartin trap "rm -f $LIST" EXIT 741.1Smartin 751.2Smartin sh -ec 'npftest -L || printf "dummy\tnone\n"' > $LIST 2>/dev/null 761.1Smartin 771.1Smartin while read tag desc 781.1Smartin do 791.1Smartin add_test "${tag}" "${desc}" 801.1Smartin done < $LIST 811.1Smartin} 82