From owner-svn-src-user@freebsd.org Tue Nov 17 00:32:41 2015 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 45CBCA31455 for ; Tue, 17 Nov 2015 00:32:41 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 034281489; Tue, 17 Nov 2015 00:32:40 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tAH0WdXu037379; Tue, 17 Nov 2015 00:32:40 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAH0WdQR037378; Tue, 17 Nov 2015 00:32:39 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201511170032.tAH0WdQR037378@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Tue, 17 Nov 2015 00:32:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r290963 - user/ngie/more-tests2/sbin/geom/class/tests/gate X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2015 00:32:41 -0000 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