mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 09:41:03 -04:00
syslogd: Fix tests when if_epair is not loaded
Take a cue from vnet.subr and abstract module loading, jail creation and cleanup. Note that the way jails are created differs slightly from vnet.subr, to maintain the current style of the tests. Reported by: Jenkins Reviewed by: markj Approved by: emaste (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D48949
This commit is contained in:
parent
65cc5af1cf
commit
8d9c25c4e1
2 changed files with 55 additions and 11 deletions
|
|
@ -323,7 +323,7 @@ jail_noinet_body()
|
|||
{
|
||||
local logfile
|
||||
|
||||
atf_check jail -c name=syslogd_noinet persist
|
||||
syslogd_mkjail syslogd_noinet
|
||||
|
||||
logfile="${PWD}/jail_noinet.log"
|
||||
printf "user.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}"
|
||||
|
|
@ -335,7 +335,7 @@ jail_noinet_body()
|
|||
}
|
||||
jail_noinet_cleanup()
|
||||
{
|
||||
jail -r syslogd_noinet
|
||||
syslogd_cleanup
|
||||
}
|
||||
|
||||
# Create a pair of jails, connected by an epair. The idea is to run syslogd in
|
||||
|
|
@ -344,10 +344,12 @@ jail_noinet_cleanup()
|
|||
# 169.254.0.2 or 169.254.0.3.
|
||||
allowed_peer_test_setup()
|
||||
{
|
||||
syslogd_check_req epair
|
||||
|
||||
local epair
|
||||
|
||||
atf_check jail -c name=syslogd_allowed_peer vnet persist
|
||||
atf_check jail -c name=syslogd_client vnet persist
|
||||
syslogd_mkjail syslogd_allowed_peer vnet
|
||||
syslogd_mkjail syslogd_client vnet
|
||||
|
||||
atf_check -o save:epair ifconfig epair create
|
||||
epair=$(cat epair)
|
||||
|
|
@ -364,9 +366,7 @@ allowed_peer_test_setup()
|
|||
|
||||
allowed_peer_test_cleanup()
|
||||
{
|
||||
jail -r syslogd_allowed_peer
|
||||
jail -r syslogd_client
|
||||
ifconfig $(cat epair) destroy
|
||||
syslogd_cleanup
|
||||
}
|
||||
|
||||
atf_test_case allowed_peer "cleanup"
|
||||
|
|
@ -499,19 +499,21 @@ forward_head()
|
|||
}
|
||||
forward_body()
|
||||
{
|
||||
syslogd_check_req epair
|
||||
|
||||
local epair logfile
|
||||
|
||||
atf_check -o save:epair ifconfig epair create
|
||||
epair=$(cat epair)
|
||||
epair=${epair%%a}
|
||||
|
||||
atf_check jail -c name=syslogd_server vnet persist
|
||||
syslogd_mkjail syslogd_server vnet
|
||||
atf_check ifconfig ${epair}a vnet syslogd_server
|
||||
atf_check jexec syslogd_server ifconfig ${epair}a inet 169.254.0.1/16
|
||||
atf_check jexec syslogd_server ifconfig ${epair}a alias 169.254.0.2/16
|
||||
atf_check jexec syslogd_server ifconfig lo0 inet 127.0.0.1/8
|
||||
|
||||
atf_check jail -c name=syslogd_client vnet persist
|
||||
syslogd_mkjail syslogd_client vnet
|
||||
atf_check ifconfig ${epair}b vnet syslogd_client
|
||||
atf_check jexec syslogd_client ifconfig ${epair}b inet 169.254.0.3/16
|
||||
atf_check jexec syslogd_client ifconfig lo0 inet 127.0.0.1/8
|
||||
|
|
@ -545,8 +547,7 @@ __EOF__
|
|||
}
|
||||
forward_cleanup()
|
||||
{
|
||||
jail -r syslogd_server
|
||||
jail -r syslogd_client
|
||||
syslogd_cleanup
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
|
|
|
|||
|
|
@ -115,3 +115,46 @@ syslogd_stop()
|
|||
rm -f "${pid_file}" "${socket_file}" "${privsocket_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check required kernel module.
|
||||
syslogd_check_req()
|
||||
{
|
||||
type=$1
|
||||
|
||||
if kldstat -q -n if_${type}.ko; then
|
||||
return
|
||||
fi
|
||||
|
||||
if ! kldload -n -q if_${type}; then
|
||||
atf_skip "if_${type}.ko is required to run this test."
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
# Make a jail and save its name to the created_jails.lst file.
|
||||
# Accepts a name and optional arguments.
|
||||
syslogd_mkjail()
|
||||
{
|
||||
jailname=$1
|
||||
shift
|
||||
args=$*
|
||||
|
||||
atf_check jail -c name=${jailname} ${args} persist
|
||||
|
||||
echo $jailname >> created_jails.lst
|
||||
}
|
||||
|
||||
# Remove epair interfaces and jails.
|
||||
syslogd_cleanup()
|
||||
{
|
||||
if [ -f created_jails.lst ]; then
|
||||
while read jailname; do
|
||||
jail -r ${jailname}
|
||||
done < created_jails.lst
|
||||
rm created_jails.lst
|
||||
fi
|
||||
|
||||
if [ -f epair ]; then
|
||||
ifconfig $(cat epair) destroy
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue