Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Feb 2017 00:15:24 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r313753 - in stable/11: . tests/sys/geom/class/gate
Message-ID:  <201702150015.v1F0FO5l026454@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Feb 15 00:15:24 2017
New Revision: 313753
URL: https://svnweb.freebsd.org/changeset/base/313753

Log:
  MFC r311893, r313008, r313081
  
  r311893:
  ATFify the geom gate tests.
  
  This ensures their cleanup routines will be run even if they should timeout.
  
  tests/sys/geom/class/gate/ggate_test.sh
  tests/sys/geom/class/gate/Makefile
  	Add an ATF test with three testcases, one for each TAP test. Use
  	ATF-style cleanup functions, and convert sleeps to polling loops.
  
  ObsoleteFiles.inc
  tests/sys/geom/class/gate/conf.sh
  tests/sys/geom/class/gate/1_test.sh
  tests/sys/geom/class/gate/2_test.sh
  tests/sys/geom/class/gate/3_test.sh
  	Delete TAP test files
  
  Reviewed by:	ngie
  MFC after:	4 weeks
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D8891
  
  r313008:
  Wait for /dev/ggate* to appear after calling `ggatel create` in :ggatel_{file,md}
  
  The test assumed that `ggatel create` created a device on completion, but that's
  incorrect. This squashes the race by waiting for the device to appear, as
  `ggatel create` daemonizes before issuing an ioctl to geom_gate(4) if not called
  with `-v`.
  
  Discussed with:	asomers
  MFC after:	1 week
  PR:		204616
  Sponsored by:	Dell EMC Isilon
  
  r313081:
  Replace for/retry loops with "wait_for_ggate_device" calls and check
  results of commands
  
  As noted in r313008, the underlying issue was that geom_gate device
  creation wasn't created at ggatel command completion, but some short
  time after. ggatec(8) employs similar logic when creating geom_gate(4)
  devices.
  
  Switch from retry loops (after the ggatec/dd write calls) to
  wait_for_ggate_device function calls after calling ggatec(8) instead
  to detect the presence of the /dev/ggate* device, as this function is
  sufficient for determining whether or not the character device is ready
  for testing
  
  While here, use atf_check consistently with all dd calls to ensure that
  data output is as expected.
  
  MFC after:	1 week
  Reviewed by:	asomers
  Differential Revision:	D9409
  Sponsored by:	Dell EMC Isilon

Added:
  stable/11/tests/sys/geom/class/gate/ggate_test.sh
     - copied, changed from r311893, head/tests/sys/geom/class/gate/ggate_test.sh
Deleted:
  stable/11/tests/sys/geom/class/gate/1_test.sh
  stable/11/tests/sys/geom/class/gate/2_test.sh
  stable/11/tests/sys/geom/class/gate/3_test.sh
  stable/11/tests/sys/geom/class/gate/conf.sh
Modified:
  stable/11/ObsoleteFiles.inc
  stable/11/tests/sys/geom/class/gate/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/ObsoleteFiles.inc
==============================================================================
--- stable/11/ObsoleteFiles.inc	Tue Feb 14 22:46:39 2017	(r313752)
+++ stable/11/ObsoleteFiles.inc	Wed Feb 15 00:15:24 2017	(r313753)
@@ -38,6 +38,11 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20170214: Four files from ggate tests consolidated into one
+OLD_FILES+=usr/tests/sys/geom/class/gate/1_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/2_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/3_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/conf.sh
 # 20170211: libarchive ACL pax test renamed to test_acl_pax_posix1e.tar.uu
 OLD_FILES+=usr/tests/lib/libarchive/test_acl_pax.tar.uu
 # 20170103: libbsnmptools.so made into an INTERNALLIB

Modified: stable/11/tests/sys/geom/class/gate/Makefile
==============================================================================
--- stable/11/tests/sys/geom/class/gate/Makefile	Tue Feb 14 22:46:39 2017	(r313752)
+++ stable/11/tests/sys/geom/class/gate/Makefile	Wed Feb 15 00:15:24 2017	(r313753)
@@ -4,14 +4,6 @@ PACKAGE=	tests
 
 TESTSDIR=	${TESTSBASE}/sys/geom/class/${.CURDIR:T}
 
-TAP_TESTS_SH+=	1_test
-TAP_TESTS_SH+=	2_test
-TAP_TESTS_SH+=	3_test
-
-${PACKAGE}FILES+=		conf.sh
-
-.for t in ${TAP_TESTS_SH}
-TEST_METADATA.$t+=	required_user="root"
-.endfor
+ATF_TESTS_SH+=	ggate_test
 
 .include <bsd.test.mk>

Copied and modified: stable/11/tests/sys/geom/class/gate/ggate_test.sh (from r311893, head/tests/sys/geom/class/gate/ggate_test.sh)
==============================================================================
--- head/tests/sys/geom/class/gate/ggate_test.sh	Tue Jan 10 20:35:09 2017	(r311893, copy source)
+++ stable/11/tests/sys/geom/class/gate/ggate_test.sh	Wed Feb 15 00:15:24 2017	(r313753)
@@ -4,7 +4,6 @@ PIDFILE=ggated.pid
 PLAINFILES=plainfiles
 PORT=33080
 CONF=gg.exports
-RETRIES=16
 
 atf_test_case ggated cleanup
 ggated_head()
@@ -21,31 +20,23 @@ ggated_body()
 	work=$(alloc_md)
 	src=$(alloc_md)
 
-	dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc
-	dd if=/dev/random of=/dev/$src bs=1m count=1 conv=notrunc
+	atf_check -e ignore -o ignore \
+	    dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc
+	atf_check -e ignore -o ignore \
+	    dd if=/dev/random of=/dev/$src bs=1m count=1 conv=notrunc
 
 	echo $CONF >> $PLAINFILES
 	echo "127.0.0.1 RW /dev/$work" > $CONF
 
 	atf_check ggated -p $PORT -F $PIDFILE $CONF
-	for try in `jot $RETRIES`; do
-		ggatec create -p $PORT -u $us 127.0.0.1 /dev/$work && break
-		# wait for ggated to be ready
-		sleep 0.25
-	done
-	if [ "$try" -eq "$RETRIES" ]; then
-		atf_fail "ggatec create failed"
-	fi
+	atf_check ggatec create -p $PORT -u $us 127.0.0.1 /dev/$work
 
-	for try in `jot $RETRIES`; do
-		dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1 conv=notrunc\
-			&& break
-		# Wait for /dev/ggate${us} to be ready
-		sleep 0.25
-	done
-	if [ "$try" -eq "$RETRIES" ]; then
-		atf_fail "dd failed; /dev/ggate${us} isn't working"
-	fi
+	ggate_dev=/dev/ggate${us}
+
+	wait_for_ggate_device ${ggate_dev}
+
+	atf_check -e ignore -o ignore \
+	    dd if=/dev/${src} of=${ggate_dev} bs=1m count=1 conv=notrunc
 
 	checksum /dev/$src /dev/$work
 }
@@ -74,7 +65,12 @@ ggatel_file_body()
 
 	atf_check ggatel create -u $us work
 
-	dd if=src of=/dev/ggate${us} bs=1m count=1 conv=notrunc
+	ggate_dev=/dev/ggate${us}
+
+	wait_for_ggate_device ${ggate_dev}
+
+	atf_check -e ignore -o ignore \
+	    dd if=src of=${ggate_dev} bs=1m count=1 conv=notrunc
 
 	checksum src work
 }
@@ -99,12 +95,19 @@ ggatel_md_body()
 	work=$(alloc_md)
 	src=$(alloc_md)
 
-	dd if=/dev/random of=$work bs=1m count=1 conv=notrunc
-	dd if=/dev/random of=$src bs=1m count=1 conv=notrunc
+	atf_check -e ignore -o ignore \
+	    dd if=/dev/random of=$work bs=1m count=1 conv=notrunc
+	atf_check -e ignore -o ignore \
+	    dd if=/dev/random of=$src bs=1m count=1 conv=notrunc
 
 	atf_check ggatel create -u $us /dev/$work
 
-	dd if=/dev/$src of=/dev/ggate${us} bs=1m count=1 conv=notrunc
+	ggate_dev=/dev/ggate${us}
+
+	wait_for_ggate_device ${ggate_dev}
+
+	atf_check -e ignore -o ignore \
+	    dd if=/dev/$src of=${ggate_dev} bs=1m count=1 conv=notrunc
 
 	checksum /dev/$src /dev/$work
 }
@@ -191,3 +194,14 @@ common_cleanup()
 	fi
 	true
 }
+
+# Bug 204616: ggatel(8) creates /dev/ggate* asynchronously if `ggatel create`
+#             isn't called with `-v`.
+wait_for_ggate_device()
+{
+	ggate_device=$1
+
+	while [ ! -c $ggate_device ]; do
+		sleep 0.5
+	done
+}



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