From owner-svn-src-user@freebsd.org Tue Nov 17 00:27:46 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 D4939A312D1 for ; Tue, 17 Nov 2015 00:27:46 +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 882A51FBA; Tue, 17 Nov 2015 00:27:46 +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 tAH0Rj9I034639; Tue, 17 Nov 2015 00:27:45 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAH0Rj5w034638; Tue, 17 Nov 2015 00:27:45 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201511170027.tAH0Rj5w034638@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:27:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r290962 - 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:27:46 -0000 Author: ngie Date: Tue Nov 17 00:27:45 2015 New Revision: 290962 URL: https://svnweb.freebsd.org/changeset/base/290962 Log: - Don't hardcode the test unit as `45`; use 47 instead - 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 Modified: user/ngie/more-tests2/sbin/geom/class/tests/gate/3_test.sh Modified: user/ngie/more-tests2/sbin/geom/class/tests/gate/3_test.sh ============================================================================== --- user/ngie/more-tests2/sbin/geom/class/tests/gate/3_test.sh Mon Nov 16 23:41:19 2015 (r290961) +++ user/ngie/more-tests2/sbin/geom/class/tests/gate/3_test.sh Tue Nov 17 00:27:45 2015 (r290962) @@ -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 >/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) + +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 >/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 - -ggatel destroy -u $us -mdconfig -d -u $us -mdconfig -d -u `expr $us + 1`