Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/netpfil/pf/utils.subr
- This file was added.
# $FreeBSD$ | |||||
# Utility functions | |||||
## | |||||
pft_init() | |||||
{ | |||||
if [ ! -c /dev/pf ]; then | |||||
atf_skip "This test requires pf" | |||||
asomers: ATF tests aren't supposed to modify the host system any more than necessary. I would recommend… | |||||
Not Done Inline ActionsOnce this goes in I will see about getting the ci scripts to load pf (and install scapy) in the test-VM so these tests get executed as well. kp: Once this goes in I will see about getting the ci scripts to load pf (and install scapy) in the… | |||||
fi | |||||
if [ "`sysctl -i -n kern.features.vimage`" != 1 ]; then | |||||
atf_skip "This test requires VIMAGE" | |||||
fi | |||||
} | |||||
Done Inline ActionsIn the unlikely event that your test crashes during setup, the cleanup must still succeed. So I wouldn't bother creating these files during setup. Instead, handle their potential nonexistence during cleanup. asomers: In the unlikely event that your test crashes during setup, the cleanup must still succeed. So… | |||||
pft_mkepair() | |||||
{ | |||||
ifname=$(ifconfig epair create) | |||||
echo $ifname >> created_interfaces.lst | |||||
echo ${ifname%a} | |||||
} | |||||
pft_mkjail() | |||||
{ | |||||
jailname=$1 | |||||
ifname=$2 | |||||
jail -c name=${jailname} persist vnet vnet.interface=${ifname} | |||||
echo $jailname >> created_jails.lst | |||||
} | |||||
pft_cleanup() | |||||
{ | |||||
if [ -f created_interfaces.lst ]; then | |||||
for ifname in `cat created_interfaces.lst` | |||||
do | |||||
ifconfig ${ifname} destroy | |||||
done | |||||
fi | |||||
if [ -f created_jails.lst ]; then | |||||
for jailname in `cat created_jails.lst` | |||||
do | |||||
jail -r ${jailname} | |||||
done | |||||
fi | |||||
} |
ATF tests aren't supposed to modify the host system any more than necessary. I would recommend not loading a kld here. Instead, check if it's already loaded, and skip if it isn't.