Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/netinet6/utils.subr
- This file was added.
# $FreeBSD$ | |||||
# Utility functions | |||||
## | |||||
v6_init() | |||||
{ | |||||
if [ "`sysctl -i -n kern.features.vimage`" != 1 ]; then | |||||
atf_skip "This test requires VIMAGE" | |||||
fi | |||||
} | |||||
v6_mkepair() | |||||
{ | |||||
ifname=$(ifconfig epair create) | |||||
echo $ifname >> created_interfaces.lst | |||||
echo ${ifname%a} | |||||
} | |||||
v6_mktarget() | |||||
{ | |||||
LOCAL="$1/64" | |||||
REMOTE="$2/64" | |||||
epair=$(v6_mkepair) | |||||
v6_mkjail jail1 ${epair}a | |||||
asomers: Every single test is trying to create a jail with the same name. That means that no two of… | |||||
ifconfig ${epair}b inet6 ${LOCAL} no_dad up | |||||
jexec jail1 ifconfig ${epair}a inet6 ${REMOTE} no_dad up | |||||
LOCAL_MAC="$(ifconfig ${epair}b | grep ether | awk '{ print $2}')" | |||||
REMOTE_MAC="$(jexec jail1 ifconfig ${epair}a | grep ether | awk '{ print $2}')" | |||||
LOCAL_IF="${epair}b" | |||||
} | |||||
v6_mkjail() | |||||
{ | |||||
jailname=$1 | |||||
shift | |||||
vnet_interfaces= | |||||
for ifname in $@ | |||||
do | |||||
vnet_interfaces="${vnet_interfaces} vnet.interface=${ifname}" | |||||
done | |||||
jail -c name=${jailname} persist vnet ${vnet_interfaces} | |||||
echo $jailname >> created_jails.lst | |||||
} | |||||
v6_runscapytest() | |||||
{ | |||||
BASE_FOLDER=$1 | |||||
TEST_SCRIPT=$2 | |||||
LOCAL_IF=$3 | |||||
LOCAL_MAC=$4 | |||||
REMOTE_MAC=$5 | |||||
LOCAL_ADDR6=$6 | |||||
REMOTE_ADDR6=$7 | |||||
ADDR_FILE=addr.py | |||||
echo "LOCAL_IF = '${LOCAL_IF}'" >> $ADDR_FILE | |||||
echo "LOCAL_MAC = '${LOCAL_MAC}'" >> $ADDR_FILE | |||||
echo "REMOTE_MAC = '${REMOTE_MAC}'" >> $ADDR_FILE | |||||
echo "LOCAL_ADDR6 = '${LOCAL_ADDR6}'" >> $ADDR_FILE | |||||
echo "REMOTE_ADDR6 = '${REMOTE_ADDR6}'" >> $ADDR_FILE | |||||
cp $(atf_get_srcdir)/$TEST_SCRIPT . | |||||
atf_check -s exit:0 -o ignore python2.7 $TEST_SCRIPT | |||||
} | |||||
v6_scapytest() | |||||
{ | |||||
BASE_FOLDER=$1 | |||||
asomersUnsubmitted Not Done Inline ActionsThis BASE_FOLDER argument seems to be unused. Why not eliminate it? asomers: This `BASE_FOLDER` argument seems to be unused. Why not eliminate it? | |||||
TEST_SCRIPT=$2 | |||||
LOCAL_ADDR6="2001:db8:42::1" | |||||
REMOTE_ADDR6="2001:db8:42::2" | |||||
v6_mktarget $LOCAL_ADDR6 $REMOTE_ADDR6 | |||||
v6_runscapytest $BASE_FOLDER $TEST_SCRIPT $LOCAL_IF $LOCAL_MAC $REMOTE_MAC $LOCAL_ADDR6 $REMOTE_ADDR6 | |||||
} | |||||
v6_cleanup() | |||||
{ | |||||
if [ -f created_jails.lst ]; then | |||||
for jailname in `cat created_jails.lst` | |||||
do | |||||
jail -r ${jailname} | |||||
done | |||||
rm created_jails.lst | |||||
fi | |||||
if [ -f created_interfaces.lst ]; then | |||||
for ifname in `cat created_interfaces.lst` | |||||
do | |||||
ifconfig ${ifname} destroy | |||||
done | |||||
rm created_interfaces.lst | |||||
fi | |||||
} |
Every single test is trying to create a jail with the same name. That means that no two of these tests can run together. So you'll have to put TEST_METADATA+= is_exclusive=true in the Makefile. Or better yet, you can embed the test case's name into the jail's name. That would be good anyway, in case something outside of this test suite creates "jail1".