svn commit: r296817 - stable/9/tools/regression/geom_gate

Garrett Cooper ngie at FreeBSD.org
Mon Mar 14 00:40:59 UTC 2016


Author: ngie
Date: Mon Mar 14 00:40:57 2016
New Revision: 296817
URL: https://svnweb.freebsd.org/changeset/base/296817

Log:
  MFstable/10 r296814:
  
  MFC r293621,r293622,r293815:
  
  r293621:
  
  - Delete non-TAP testcases
  - Add a conf.sh file for executing common functions with geom_gate
  - Use attach_md for attaching md(4) devices
  - Don't hardcode /tmp for temporary files, which violates the kyua sandbox
  - Add/increase sleeps to try and improve synchronization
  - Add debug output for when checksums fail
  
  test-1.t:
  - Use pkill for killing ggated
  
  r293622:
  
  Remove Makefile now that the testcases are all TAP based and
  prove -rv can be used on them
  
  r293815:
  
  Add conf.sh file missed in r293621

Added:
  stable/9/tools/regression/geom_gate/conf.sh
     - copied unchanged from r296814, stable/10/tools/regression/geom_gate/conf.sh
Deleted:
  stable/9/tools/regression/geom_gate/Makefile
  stable/9/tools/regression/geom_gate/runtests.sh
  stable/9/tools/regression/geom_gate/test-1.sh
  stable/9/tools/regression/geom_gate/test-2.sh
  stable/9/tools/regression/geom_gate/test-3.sh
Modified:
  stable/9/tools/regression/geom_gate/test-1.t
  stable/9/tools/regression/geom_gate/test-2.t
  stable/9/tools/regression/geom_gate/test-3.t
Directory Properties:
  stable/9/   (props changed)
  stable/9/tools/   (props changed)
  stable/9/tools/regression/   (props changed)

Copied: stable/9/tools/regression/geom_gate/conf.sh (from r296814, stable/10/tools/regression/geom_gate/conf.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/tools/regression/geom_gate/conf.sh	Mon Mar 14 00:40:57 2016	(r296817, copy of r296814, stable/10/tools/regression/geom_gate/conf.sh)
@@ -0,0 +1,10 @@
+#!/bin/sh
+# $FreeBSD$
+
+name="$(mktemp -u gate.XXXXXX)"
+class="gate"
+base=`basename $0`
+
+kldstat -q -m g_${class} || kldload geom_${class} || exit 1
+
+. `dirname $0`/../geom_subr.sh

Modified: stable/9/tools/regression/geom_gate/test-1.t
==============================================================================
--- stable/9/tools/regression/geom_gate/test-1.t	Mon Mar 14 00:34:12 2016	(r296816)
+++ stable/9/tools/regression/geom_gate/test-1.t	Mon Mar 14 00:40:57 2016	(r296817)
@@ -1,40 +1,62 @@
 #!/bin/sh
 # $FreeBSD$
 
-base=`basename $0`
-us=45
-work="/dev/md${us}"
-src="/dev/md`expr $us + 1`"
-conf=`mktemp /tmp/$base.XXXXXX` || exit 1
-
-mdconfig -a -t malloc -s 1M -u $us || exit 1
-mdconfig -a -t malloc -s 1M -u `expr $us + 1` || exit 1
-dd if=/dev/random of=$work bs=1m count=1 >/dev/null 2>&1
-dd if=/dev/random of=$src bs=1m count=1 >/dev/null 2>&1
-sum=`cat $src | md5 -q`
-
-echo "127.0.0.1 RW $work" > $conf
-ggated $conf
-ggatec create -u $us 127.0.0.1 $work
-
-dd if=${src} of=/dev/ggate${us} bs=1m count=1 >/dev/null 2>&1
+. `dirname $0`/conf.sh
 
 echo '1..2'
 
-if [ `cat $work | md5 -q` != $sum ]; then
-	echo 'not ok 1 - md5 checksum'
+base=`basename $0`
+us=0
+while [ -c /dev/ggate${us} ]; do
+	: $(( us += 1 ))
+done
+conf=`mktemp $base.XXXXXX` || exit 1
+pidfile=/var/run/ggated.pid
+port=33080
+
+work=$(attach_md -t malloc -s 1M)
+src=$(attach_md -t malloc -s 1M)
+
+test_cleanup()
+{
+	ggatec destroy -f -u $us
+	pkill -F $pidfile
+	geom_test_cleanup
+}
+trap test_cleanup ABRT EXIT INT TERM
+
+dd if=/dev/random of=/dev/$work bs=1m count=1 conv=sync
+dd if=/dev/random of=/dev/$src bs=1m count=1 conv=sync
+src_checksum=$(md5 -q /dev/$src)
+
+echo "127.0.0.1 RW /dev/$work" > $conf
+
+if ! ggated -p $port $conf; then
+	echo 'ggated failed to start'
+	echo 'Bail out!'
+	exit 1
+fi
+sleep 1
+if ! ggatec create -p $port -u $us 127.0.0.1 /dev/$work; then
+	echo 'ggatec create failed'
+	echo 'Bail out!'
+	exit 1
+fi
+
+dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1
+sleep 1
+
+work_checksum=$(md5 -q /dev/$work)
+if [ "$work_checksum" != "$src_checksum" ]; then
+	echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum)"
+	echo "not ok 2 # SKIP"
 else
 	echo 'ok 1 - md5 checksum'
 
-	if [ `cat /dev/ggate${us} | md5 -q` != $sum ]; then
-		echo 'not ok 2 - md5 checksum'
+	ggate_checksum=$(md5 -q /dev/ggate${us})
+	if [ "$ggate_checksum" != "$src_checksum" ]; then
+		echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)"
 	else
 		echo 'ok 2 - md5 checksum'
 	fi
 fi
-
-ggatec destroy -u $us
-mdconfig -d -u $us
-mdconfig -d -u `expr $us + 1`
-pkill ggated $conf
-rm -f $conf

Modified: stable/9/tools/regression/geom_gate/test-2.t
==============================================================================
--- stable/9/tools/regression/geom_gate/test-2.t	Mon Mar 14 00:34:12 2016	(r296816)
+++ stable/9/tools/regression/geom_gate/test-2.t	Mon Mar 14 00:40:57 2016	(r296817)
@@ -1,31 +1,48 @@
 #!/bin/sh
 # $FreeBSD$
 
-base=`basename $0`
-us=45
-work=`mktemp /tmp/$base.XXXXXX` || exit 1
-src=`mktemp /tmp/$base.XXXXXX` || exit 1
-
-dd if=/dev/random of=$work bs=1m count=1 >/dev/null 2>&1
-dd if=/dev/random of=$src bs=1m count=1 >/dev/null 2>&1
-sum=`md5 -q $src`
+. `dirname $0`/conf.sh
 
-ggatel create -u $us $work
+base=`basename $0`
+us=46
+work=`mktemp -u $base.XXXXXX` || exit 1
+src=`mktemp -u $base.XXXXXX` || exit 1
+
+test_cleanup()
+{
+	ggatel destroy -f -u $us
+	rm -f $work $src
+
+	geom_test_cleanup
+}
+trap test_cleanup ABRT EXIT INT TERM
+
+dd if=/dev/random of=$work bs=1m count=1 conv=sync
+dd if=/dev/random of=$src bs=1m count=1 conv=sync
+
+if ! ggatel create -u $us $work; then
+	echo 'ggatel create failed'
+	echo 'Bail out!'
+	exit 1
+fi
 
-dd if=${src} of=/dev/ggate${us} bs=1m count=1 >/dev/null 2>&1
+dd if=${src} of=/dev/ggate${us} bs=1m count=1
+sleep 1
 
 echo '1..2'
 
-if [ `md5 -q $work` != $sum ]; then
-	echo 'not ok 1 - md5 checksum'
+src_checksum=$(md5 -q $src)
+work_checksum=$(md5 -q $work)
+if [ "$work_checksum" != "$src_checksum" ]; then
+	echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum) # TODO: bug 204616"
+	echo 'not ok 2 # SKIP'
 else
 	echo 'ok 1 - md5 checksum'
-	if [ `cat /dev/ggate${us} | md5 -q` != $sum ]; then
-		echo 'not ok 2 - md5 checksum'
+
+	ggate_checksum=$(md5 -q /dev/ggate${us})
+	if [ "$ggate_checksum" != "$src_checksum" ]; then
+		echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)"
 	else
 		echo 'ok 2 - md5 checksum'
 	fi
 fi
-
-ggatel destroy -u $us
-rm -f $work $src

Modified: stable/9/tools/regression/geom_gate/test-3.t
==============================================================================
--- stable/9/tools/regression/geom_gate/test-3.t	Mon Mar 14 00:34:12 2016	(r296816)
+++ stable/9/tools/regression/geom_gate/test-3.t	Mon Mar 14 00:40:57 2016	(r296817)
@@ -1,34 +1,48 @@
 #!/bin/sh
 # $FreeBSD$
 
+. `dirname $0`/conf.sh
+
 base=`basename $0`
-us=45
-work="/dev/md${us}"
-src="/dev/md`expr $us + 1`"
-
-mdconfig -a -t malloc -s 1M -u $us || exit 1
-mdconfig -a -t malloc -s 1M -u `expr $us + 1` || exit 1
-dd if=/dev/random of=$work bs=1m count=1 >/dev/null 2>&1
-dd if=/dev/random of=$src bs=1m count=1 >/dev/null 2>&1
-sum=`cat $src | md5 -q`
+us=47
 
-ggatel create -u $us $work
+test_cleanup()
+{
+	ggatel destroy -f -u $us
+
+	geom_test_cleanup
+}
+trap test_cleanup ABRT EXIT INT TERM
+
+work=$(attach_md -t malloc -s 1M)
+src=$(attach_md -t malloc -s 1M)
+
+dd if=/dev/random of=/dev/$work bs=1m count=1 conv=sync
+dd if=/dev/random of=/dev/$src bs=1m count=1 conv=sync
+src_checksum=$(md5 -q /dev/$src)
+
+if ! ggatel create -u $us /dev/$work; then
+	echo 'ggatel create failed'
+	echo 'Bail out!'
+	exit 1
+fi
 
-dd if=${src} of=/dev/ggate${us} bs=1m count=1 >/dev/null 2>&1
+dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1 conv=sync
+sleep 1
 
 echo '1..2'
 
-if [ `cat $work | md5 -q` != $sum ]; then
-	echo 'not ok 1 - md5 checksum'
+work_checksum=$(md5 -q /dev/$work)
+if [ "$work_checksum" != "$src_checksum" ]; then
+	echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum)"
+	echo 'not ok 2 # SKIP'
 else
 	echo 'ok 1 - md5 checksum'
-	if [ `cat /dev/ggate${us} | md5 -q` != $sum ]; then
-		echo 'not ok 2 - md5 checksum'
+
+	ggate_checksum=$(md5 -q /dev/ggate${us})
+	if [ "$ggate_checksum" != "$src_checksum" ]; then
+		echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)"
 	else
 		echo 'ok 2 - md5 checksum'
 	fi
 fi
-
-ggatel destroy -u $us
-mdconfig -d -u $us
-mdconfig -d -u `expr $us + 1`


More information about the svn-src-stable-9 mailing list