From a1180534c625db7b77464c4f999c398e0bac4fc8 Mon Sep 17 00:00:00 2001 From: asomers Date: Tue, 18 Apr 2017 16:17:38 +0000 Subject: [PATCH] MFC r285117 Make cleanup routines idempotent cleanup routines can be executed at any point during the execution of the body, including even before the body has done any real work. In those cases, cleanup routines should be careful to not raise spurious errors so as to not "override" the actual result of the test case. This is just general good coding style but is not a problem in practice for these specific tests. (The way I discovered the issue, though, was due to a regression I introduced in Kyua itself while refactoring some internals.) MFC after: 1 week git-svn-id: svn://svn.freebsd.org/base/stable/10@317093 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- tests/sys/netinet/fibs_test.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/sys/netinet/fibs_test.sh b/tests/sys/netinet/fibs_test.sh index 72ebcfca1..75845a65d 100755 --- a/tests/sys/netinet/fibs_test.sh +++ b/tests/sys/netinet/fibs_test.sh @@ -98,9 +98,12 @@ arpresolve_checks_interface_fib_body() } arpresolve_checks_interface_fib_cleanup() { - for PID in `cat "processes_to_kill"`; do - kill $PID - done + if [ -f processes_to_kill ]; then + for pid in $(cat processes_to_kill); do + kill "${pid}" + done + rm -f processes_to_kill + fi cleanup_tap } @@ -477,8 +480,10 @@ setup_tap() cleanup_tap() { - for TAPD in `cat "tap_devices_to_cleanup"`; do - ifconfig ${TAPD} destroy - done - rm "tap_devices_to_cleanup" + if [ -f tap_devices_to_cleanup ]; then + for tap_device in $(cat tap_devices_to_cleanup); do + ifconfig "${tap_device}" destroy + done + rm -f tap_devices_to_cleanup + fi } -- 2.45.0