Date: Tue, 17 Nov 2015 00:32:39 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r290963 - user/ngie/more-tests2/sbin/geom/class/tests/gate Message-ID: <201511170032.tAH0WdQR037378@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Tue Nov 17 00:32:39 2015 New Revision: 290963 URL: https://svnweb.freebsd.org/changeset/base/290963 Log: - Use conf.sh - Consolidate the cleanup steps and always execute on exit - Use attach_md to track md(4) devices - Be more verbose on md5 failure - Use better variable names - Specify a non-standard pidfile path and port number to avoid collisions with other instances of ggated on the test host Modified: user/ngie/more-tests2/sbin/geom/class/tests/gate/1_test.sh Modified: user/ngie/more-tests2/sbin/geom/class/tests/gate/1_test.sh ============================================================================== --- user/ngie/more-tests2/sbin/geom/class/tests/gate/1_test.sh Tue Nov 17 00:27:45 2015 (r290962) +++ user/ngie/more-tests2/sbin/geom/class/tests/gate/1_test.sh Tue Nov 17 00:32:39 2015 (r290963) @@ -1,40 +1,58 @@ #!/bin/sh # $FreeBSD$ +. `dirname $0`/conf.sh + 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 +conf=`mktemp $base.XXXXXX` || exit 1 +pidfile=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 >/dev/null 2>&1 +dd if=/dev/random of=/dev/$src bs=1m count=1 >/dev/null 2>&1 +src_checksum=$(md5 -q /dev/$src) + +echo "127.0.0.1 RW /dev/$work" > $conf + +if ! ggated -F $pidfile -p $port $conf; then + echo 'ggated failed to start' + echo 'Bail out!' + exit 1 +fi +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=${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 >/dev/null 2>&1 +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 - -ggatec destroy -u $us -mdconfig -d -u $us -mdconfig -d -u `expr $us + 1` -pkill ggated $conf -rm -f $conf
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511170032.tAH0WdQR037378>