Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Jan 2016 23:45:26 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r293621 - head/tools/regression/geom_gate
Message-ID:  <201601092345.u09NjQtD073230@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Jan  9 23:45:25 2016
New Revision: 293621
URL: https://svnweb.freebsd.org/changeset/base/293621

Log:
  - 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
  
  MFC after: 3 weeks
  Sponsored by: EMC / Isilon Storage Division

Deleted:
  head/tools/regression/geom_gate/runtests.sh
  head/tools/regression/geom_gate/test-1.sh
  head/tools/regression/geom_gate/test-2.sh
  head/tools/regression/geom_gate/test-3.sh
Modified:
  head/tools/regression/geom_gate/test-1.t
  head/tools/regression/geom_gate/test-2.t
  head/tools/regression/geom_gate/test-3.t

Modified: head/tools/regression/geom_gate/test-1.t
==============================================================================
--- head/tools/regression/geom_gate/test-1.t	Sat Jan  9 23:44:41 2016	(r293620)
+++ head/tools/regression/geom_gate/test-1.t	Sat Jan  9 23:45:25 2016	(r293621)
@@ -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: head/tools/regression/geom_gate/test-2.t
==============================================================================
--- head/tools/regression/geom_gate/test-2.t	Sat Jan  9 23:44:41 2016	(r293620)
+++ head/tools/regression/geom_gate/test-2.t	Sat Jan  9 23:45:25 2016	(r293621)
@@ -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: head/tools/regression/geom_gate/test-3.t
==============================================================================
--- head/tools/regression/geom_gate/test-3.t	Sat Jan  9 23:44:41 2016	(r293620)
+++ head/tools/regression/geom_gate/test-3.t	Sat Jan  9 23:45:25 2016	(r293621)
@@ -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`



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