Date: Tue, 17 Nov 2015 00:27:45 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r290962 - user/ngie/more-tests2/sbin/geom/class/tests/gate Message-ID: <201511170027.tAH0Rj5w034638@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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`
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511170027.tAH0Rj5w034638>