Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net/ndp Kill rtadvd surely even if the tests fail in t...
details: https://anonhg.NetBSD.org/src/rev/9f3dd0fbdad5
branches: trunk
changeset: 357335:9f3dd0fbdad5
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Mon Nov 06 10:51:40 2017 +0000
description:
Kill rtadvd surely even if the tests fail in the middle
It may help PR bin/52701.
diffstat:
tests/net/ndp/t_ra.sh | 131 ++++++++++++++++++++++---------------------------
1 files changed, 58 insertions(+), 73 deletions(-)
diffs (298 lines):
diff -r fe0fbb681766 -r 9f3dd0fbdad5 tests/net/ndp/t_ra.sh
--- a/tests/net/ndp/t_ra.sh Mon Nov 06 10:26:13 2017 +0000
+++ b/tests/net/ndp/t_ra.sh Mon Nov 06 10:51:40 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ra.sh,v 1.29 2017/06/22 09:56:48 ozaki-r Exp $
+# $NetBSD: t_ra.sh,v 1.30 2017/11/06 10:51:40 ozaki-r Exp $
#
# Copyright (c) 2015 Internet Initiative Japan Inc.
# All rights reserved.
@@ -85,6 +85,34 @@
return 0
}
+kill_rtadvd()
+{
+ local pidfile=$1
+
+ kill -KILL `cat $pidfile`
+ rm -f $pidfile
+}
+
+terminate_rtadvd()
+{
+ local pidfile=$1
+ local n=5
+
+ if [ ! -f $pidfile ]; then
+ return
+ fi
+
+ kill -TERM `cat $pidfile`
+ while [ -f $pidfile ]; do
+ n=$((n - 1))
+ if [ $n = 0 ]; then
+ kill_rtadvd $pidfile
+ break
+ fi
+ sleep 0.2
+ done
+}
+
create_rtadvdconfig()
{
@@ -203,8 +231,7 @@
atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6
unset RUMP_SERVER
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
+ terminate_rtadvd $PIDFILE
export RUMP_SERVER=${RUMPCLI}
atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
@@ -215,8 +242,7 @@
check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
+ terminate_rtadvd $PIDFILE
rump_server_destroy_ifaces
}
@@ -224,12 +250,8 @@
ra_basic_cleanup()
{
- if [ -f ${PIDFILE} ]; then
- kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- fi
-
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
cleanup
}
@@ -267,7 +289,7 @@
# Terminate rtadvd to prevent new RA messages from coming
# Note that ifconfig down; kill -TERM doesn't work
- kill -KILL `cat ${PIDFILE}`
+ kill_rtadvd $PIDFILE
# Flush all the entries in the prefix list
atf_check -s exit:0 rump.ndp -P
@@ -288,6 +310,7 @@
{
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
cleanup
}
@@ -325,7 +348,7 @@
# Terminate rtadvd to prevent new RA messages from coming
# Note that ifconfig down; kill -TERM doesn't work
- kill -KILL `cat ${PIDFILE}`
+ kill_rtadvd $PIDFILE
# Flush all the entries in the default router list
atf_check -s exit:0 rump.ndp -R
@@ -345,6 +368,7 @@
{
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
cleanup
}
@@ -384,8 +408,7 @@
$(rump.ifconfig shmif0 |awk '/AUTOCONF/ {print $2}') delete
unset RUMP_SERVER
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
+ terminate_rtadvd $PIDFILE
rump_server_destroy_ifaces
}
@@ -393,12 +416,8 @@
ra_delete_address_cleanup()
{
- if [ -f ${PIDFILE} ]; then
- kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- fi
-
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
cleanup
}
@@ -444,10 +463,8 @@
atf_check_equal $n 2
unset RUMP_SERVER
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}`
- wait_term ${PIDFILE3}
+ terminate_rtadvd $PIDFILE
+ terminate_rtadvd $PIDFILE3
rump_server_destroy_ifaces
}
@@ -455,16 +472,9 @@
ra_multiple_routers_cleanup()
{
- if [ -f ${PIDFILE} ]; then
- kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- fi
- if [ -f ${PIDFILE3} ]; then
- kill -TERM `cat ${PIDFILE3}`
- wait_term ${PIDFILE3}
- fi
-
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
+ terminate_rtadvd $PIDFILE3
cleanup
}
@@ -510,10 +520,8 @@
atf_check_equal $n 1
unset RUMP_SERVER
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE1_2}`
- wait_term ${PIDFILE1_2}
+ terminate_rtadvd $PIDFILE
+ terminate_rtadvd $PIDFILE1_2
rump_server_destroy_ifaces
}
@@ -521,16 +529,9 @@
ra_multiple_routers_single_prefix_cleanup()
{
- if [ -f ${PIDFILE} ]; then
- kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- fi
- if [ -f ${PIDFILE1_2} ]; then
- kill -TERM `cat ${PIDFILE1_2}`
- wait_term ${PIDFILE1_2}
- fi
-
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
+ terminate_rtadvd $PIDFILE1_2
cleanup
}
@@ -588,12 +589,9 @@
# TODO check other conditions
unset RUMP_SERVER
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}`
- wait_term ${PIDFILE3}
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE4}`
- wait_term ${PIDFILE4}
+ terminate_rtadvd $PIDFILE
+ terminate_rtadvd $PIDFILE3
+ terminate_rtadvd $PIDFILE4
rump_server_destroy_ifaces
}
@@ -601,20 +599,10 @@
ra_multiple_routers_maxifprefixes_cleanup()
{
- if [ -f ${PIDFILE} ]; then
- kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- fi
- if [ -f ${PIDFILE3} ]; then
- kill -TERM `cat ${PIDFILE3}`
- wait_term ${PIDFILE3}
- fi
- if [ -f ${PIDFILE4} ]; then
- kill -TERM `cat ${PIDFILE4}`
- wait_term ${PIDFILE4}
- fi
-
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
+ terminate_rtadvd $PIDFILE3
+ terminate_rtadvd $PIDFILE4
cleanup
}
@@ -693,8 +681,7 @@
unset RUMP_SERVER
- atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
- wait_term $PIDFILE
+ terminate_rtadvd $PIDFILE
rump_server_destroy_ifaces
}
@@ -702,12 +689,8 @@
ra_temporary_address_cleanup()
{
- if [ -f ${PIDFILE} ]; then
- kill -TERM `cat ${PIDFILE}`
- wait_term ${PIDFILE}
- fi
-
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
cleanup
}
@@ -747,7 +730,7 @@
# Terminate rtadvd to prevent new RA messages from coming
# Note that ifconfig down; kill -TERM doesn't work
- kill -KILL `cat ${PIDFILE}`
+ kill_rtadvd $PIDFILE
# Wait until the default routers and prefix entries are expired
sleep $expire_time
@@ -772,6 +755,7 @@
{
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
cleanup
}
@@ -811,7 +795,7 @@
# Terminate rtadvd to prevent new RA messages from coming
# Note that ifconfig down; kill -TERM doesn't work
- kill -KILL `cat ${PIDFILE}`
+ kill_rtadvd $PIDFILE
# Wait until the default routers and prefix entries are expired
sleep $expire_time
@@ -837,6 +821,7 @@
{
$DEBUG && dump
+ terminate_rtadvd $PIDFILE
cleanup
}
Home |
Main Index |
Thread Index |
Old Index