Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/net/if_clone_test.sh
Show All 33 Lines | |||||
# Outline: | # Outline: | ||||
# For each cloned interface type, do three tests | # For each cloned interface type, do three tests | ||||
# 1) Create and destroy it | # 1) Create and destroy it | ||||
# 2) Create, up, and destroy it | # 2) Create, up, and destroy it | ||||
# 3) Create, disable IPv6 auto address assignment, up, and destroy it | # 3) Create, disable IPv6 auto address assignment, up, and destroy it | ||||
TESTLEN=10 # seconds | TESTLEN=10 # seconds | ||||
atf_test_case epair_stress cleanup | |||||
epair_stress_head() | |||||
{ | |||||
atf_set "descr" "Simultaneously create and destroy an epair(4)" | |||||
atf_set "require.user" "root" | |||||
} | |||||
epair_stress_body() | |||||
{ | |||||
do_stress "epair" | |||||
} | |||||
epair_stress_cleanup() | |||||
{ | |||||
cleanup_ifaces | |||||
} | |||||
atf_test_case epair_up_stress cleanup | |||||
epair_up_stress_head() | |||||
{ | |||||
atf_set "descr" "Simultaneously up and detroy an epair(4)" | |||||
atf_set "require.user" "root" | |||||
} | |||||
epair_up_stress_body() | |||||
{ | |||||
do_up_stress "epair" "" "" | |||||
} | |||||
epair_up_stress_cleanup() | |||||
{ | |||||
cleanup_ifaces | |||||
} | |||||
atf_test_case epair_ipv6_up_stress cleanup | |||||
epair_ipv6_up_stress_head() | |||||
{ | |||||
atf_set "descr" "Simultaneously up and destroy an epair(4) with IPv6" | |||||
atf_set "require.user" "root" | |||||
} | |||||
epair_ipv6_up_stress_body() | |||||
{ | |||||
atf_skip "Quickly panics: page fault in in6_unlink_ifa (PR 225438)" | |||||
asomers: Is there a PR for this panic? If not, you should create one, and link to it from here. That… | |||||
do_up_stress "epair" "6" "" | |||||
} | |||||
epair_ipv6_up_stress_cleanup() | |||||
{ | |||||
cleanup_ifaces | |||||
} | |||||
atf_test_case faith_stress cleanup | atf_test_case faith_stress cleanup | ||||
faith_stress_head() | faith_stress_head() | ||||
{ | { | ||||
atf_set "descr" "Simultaneously create and destroy a faith(4)" | atf_set "descr" "Simultaneously create and destroy a faith(4)" | ||||
atf_set "require.user" "root" | atf_set "require.user" "root" | ||||
} | } | ||||
faith_stress_body() | faith_stress_body() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
vmnet_ipv6_up_stress_cleanup() | vmnet_ipv6_up_stress_cleanup() | ||||
{ | { | ||||
cleanup_ifaces | cleanup_ifaces | ||||
} | } | ||||
atf_init_test_cases() | atf_init_test_cases() | ||||
{ | { | ||||
# TODO: add epair(4) tests, which need a different syntax | atf_add_test_case epair_ipv6_up_stress | ||||
atf_add_test_case epair_stress | |||||
atf_add_test_case epair_up_stress | |||||
atf_add_test_case faith_ipv6_up_stress | atf_add_test_case faith_ipv6_up_stress | ||||
atf_add_test_case faith_stress | atf_add_test_case faith_stress | ||||
atf_add_test_case faith_up_stress | atf_add_test_case faith_up_stress | ||||
atf_add_test_case gif_ipv6_up_stress | atf_add_test_case gif_ipv6_up_stress | ||||
atf_add_test_case gif_stress | atf_add_test_case gif_stress | ||||
atf_add_test_case gif_up_stress | atf_add_test_case gif_up_stress | ||||
# Don't test lagg; it has its own test program | # Don't test lagg; it has its own test program | ||||
atf_add_test_case lo_ipv6_up_stress | atf_add_test_case lo_ipv6_up_stress | ||||
Show All 10 Lines | atf_init_test_cases() | ||||
atf_add_test_case vlan_up_stress | atf_add_test_case vlan_up_stress | ||||
atf_add_test_case vmnet_ipv6_up_stress | atf_add_test_case vmnet_ipv6_up_stress | ||||
atf_add_test_case vmnet_stress | atf_add_test_case vmnet_stress | ||||
atf_add_test_case vmnet_up_stress | atf_add_test_case vmnet_up_stress | ||||
} | } | ||||
do_stress() | do_stress() | ||||
{ | { | ||||
local IFACE | local IFACE CREATOR_PID DESTROYER_PID | ||||
IFACE=`get_iface $1` | IFACE=`get_iface $1` | ||||
# First thread: create the interface | # First thread: create the interface | ||||
while true; do | while true; do | ||||
ifconfig $IFACE create 2>/dev/null && \ | ifconfig ${IFACE%a} create 2>/dev/null && \ | ||||
echo -n . >> creator_count.txt | echo -n . >> creator_count.txt | ||||
done & | done & | ||||
CREATOR_PID=$! | CREATOR_PID=$! | ||||
# Second thread: destroy the lagg | # Second thread: destroy the lagg | ||||
while true; do | while true; do | ||||
ifconfig $IFACE destroy 2>/dev/null && \ | ifconfig $IFACE destroy 2>/dev/null && \ | ||||
echo -n . >> destroyer_count.txt | echo -n . >> destroyer_count.txt | ||||
done & | done & | ||||
DESTROYER_PID=$! | DESTROYER_PID=$! | ||||
sleep ${TESTLEN} | sleep ${TESTLEN} | ||||
kill $CREATOR_PID | kill $CREATOR_PID | ||||
kill $DESTROYER_PID | kill $DESTROYER_PID | ||||
echo "Created $IFACE `stat -f %z creator_count.txt` times." | echo "Created ${IFACE%a} `stat -f %z creator_count.txt` times." | ||||
echo "Destroyed it `stat -f %z destroyer_count.txt` times." | echo "Destroyed it `stat -f %z destroyer_count.txt` times." | ||||
} | } | ||||
# Implement the up stress tests | # Implement the up stress tests | ||||
# Parameters | # Parameters | ||||
# $1 Interface class, etc "lo" or "tap" | # $1 Interface class, etc "lo" or "tap" | ||||
# $2 "6" to enable IPv6 auto address assignment, anything else otherwise | # $2 "6" to enable IPv6 auto address assignment, anything else otherwise | ||||
# $3 p2p for point to point interfaces, anything else for normal interfaces | # $3 p2p for point to point interfaces, anything else for normal interfaces | ||||
do_up_stress() | do_up_stress() | ||||
{ | { | ||||
local IFACE IPv6 MAC P2P SRCDIR | local ADDR DSTADDR MASK MEAN_SLEEP_SECONDS MAX_SLEEP_USECS \ | ||||
IFACE IPV6 P2P SRCDIR LOOP_PID ipv6_cmd up_cmd | |||||
# Configure the interface to use an RFC5737 nonrouteable addresses | # Configure the interface to use an RFC5737 nonrouteable addresses | ||||
ADDR="192.0.2.2" | ADDR="192.0.2.2" | ||||
DSTADDR="192.0.2.3" | DSTADDR="192.0.2.3" | ||||
MASK="24" | MASK="24" | ||||
# ifconfig takes about 10ms to run. To increase race coverage, | # ifconfig takes about 10ms to run. To increase race coverage, | ||||
# randomly delay the two commands relative to each other by 5ms either | # randomly delay the two commands relative to each other by 5ms either | ||||
# way. | # way. | ||||
Show All 19 Lines | while true; do | ||||
eval "$ipv6_cmd" | eval "$ipv6_cmd" | ||||
{ sleep ${MEAN_SLEEP_SECONDS} && \ | { sleep ${MEAN_SLEEP_SECONDS} && \ | ||||
eval "$up_cmd" 2> /dev/null && | eval "$up_cmd" 2> /dev/null && | ||||
echo -n . >> up_count.txt ; } & | echo -n . >> up_count.txt ; } & | ||||
{ ${SRCDIR}/randsleep ${MAX_SLEEP_USECS} && \ | { ${SRCDIR}/randsleep ${MAX_SLEEP_USECS} && \ | ||||
ifconfig $IFACE destroy && | ifconfig $IFACE destroy && | ||||
echo -n . >> destroy_count.txt ; } & | echo -n . >> destroy_count.txt ; } & | ||||
wait | wait | ||||
ifconfig $IFACE create | ifconfig ${IFACE%a} create | ||||
done & | done & | ||||
LOOP_PID=$! | LOOP_PID=$! | ||||
sleep ${TESTLEN} | sleep ${TESTLEN} | ||||
kill $LOOP_PID | kill $LOOP_PID | ||||
echo "Upped ${IFACE} `stat -f %z up_count.txt` times." | echo "Upped ${IFACE} `stat -f %z up_count.txt` times." | ||||
echo "Destroyed it `stat -f %z destroy_count.txt` times." | echo "Destroyed it `stat -f %z destroy_count.txt` times." | ||||
} | } | ||||
# Creates a new cloned interface, registers it for cleanup, and echoes it | # Creates a new cloned interface, registers it for cleanup, and echoes it | ||||
# params: $1 Interface class name (tap, gif, etc) | # params: $1 Interface class name (tap, gif, etc) | ||||
get_iface() | get_iface() | ||||
{ | { | ||||
local CLASS DEV N | local CLASS DEV N | ||||
CLASS=$1 | CLASS=$1 | ||||
N=0 | N=0 | ||||
while ! ifconfig ${CLASS}${N} create > /dev/null 2>&1; do | while ! ifconfig ${CLASS}${N} create > /dev/null 2>&1; do | ||||
if [ "$N" -ge 8 ]; then | if [ "$N" -ge 8 ]; then | ||||
atf_skip "Could not create a ${CLASS} interface" | atf_skip "Could not create a ${CLASS} interface" | ||||
else | else | ||||
N=$(($N + 1)) | N=$(($N + 1)) | ||||
fi | fi | ||||
done | done | ||||
local DEV=${CLASS}${N} | if [ ${CLASS} = "epair" ]; then | ||||
DEV=${CLASS}${N}a | |||||
else | |||||
DEV=${CLASS}${N} | |||||
fi | |||||
# Record the device so we can clean it up later | # Record the device so we can clean it up later | ||||
echo ${DEV} >> "devices_to_cleanup" | echo ${DEV} >> "devices_to_cleanup" | ||||
echo ${DEV} | echo ${DEV} | ||||
} | } | ||||
cleanup_ifaces() | cleanup_ifaces() | ||||
{ | { | ||||
local DEV | local DEV | ||||
for DEV in `cat "devices_to_cleanup"`; do | for DEV in `cat "devices_to_cleanup"`; do | ||||
if [ ${DEV%%[0-9]*a} = "epair" ]; then | |||||
ifconfig ${DEV}a destroy | |||||
else | |||||
ifconfig ${DEV} destroy | ifconfig ${DEV} destroy | ||||
fi | |||||
done | done | ||||
true | true | ||||
} | } |
Is there a PR for this panic? If not, you should create one, and link to it from here. That way future developers will know when they can unskip the test.