Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Jul 2015 02:22:27 +0000 (UTC)
From:      Julio Merino <jmmv@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285117 - head/tests/sys/netinet
Message-ID:  <201507040222.t642MRAY006844@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jmmv
Date: Sat Jul  4 02:22:26 2015
New Revision: 285117
URL: https://svnweb.freebsd.org/changeset/base/285117

Log:
  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

Modified:
  head/tests/sys/netinet/fibs_test.sh

Modified: head/tests/sys/netinet/fibs_test.sh
==============================================================================
--- head/tests/sys/netinet/fibs_test.sh	Sat Jul  4 01:02:43 2015	(r285116)
+++ head/tests/sys/netinet/fibs_test.sh	Sat Jul  4 02:22:26 2015	(r285117)
@@ -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
 }
 
@@ -476,8 +479,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
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507040222.t642MRAY006844>