- 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
This commit is contained in:
Enji Cooper 2016-01-09 23:45:25 +00:00
parent 7cf0da249a
commit 0f0306933a
7 changed files with 113 additions and 163 deletions

View File

@ -1,8 +0,0 @@
#!/bin/sh
# $FreeBSD$
dir=`dirname $0`
for ts in `dirname $0`/test-*.sh; do
sh $ts
done

View File

@ -1,36 +0,0 @@
#!/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
if [ `cat $work | md5 -q` != $sum ]; then
echo "FAIL"
else
if [ `cat /dev/ggate${us} | md5 -q` != $sum ]; then
echo "FAIL"
else
echo "PASS"
fi
fi
ggatec destroy -u $us
mdconfig -d -u $us
mdconfig -d -u `expr $us + 1`
pkill ggated $conf
rm -f $conf

View File

@ -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

View File

@ -1,28 +0,0 @@
#!/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`
ggatel create -u $us $work
dd if=${src} of=/dev/ggate${us} bs=1m count=1 >/dev/null 2>&1
if [ `md5 -q $work` != $sum ]; then
echo "FAIL"
else
if [ `cat /dev/ggate${us} | md5 -q` != $sum ]; then
echo "FAIL"
else
echo "PASS"
fi
fi
ggatel destroy -u $us
rm -f $work $src

View File

@ -1,31 +1,48 @@
#!/bin/sh
# $FreeBSD$
. `dirname $0`/conf.sh
base=`basename $0`
us=45
work=`mktemp /tmp/$base.XXXXXX` || exit 1
src=`mktemp /tmp/$base.XXXXXX` || exit 1
us=46
work=`mktemp -u $base.XXXXXX` || exit 1
src=`mktemp -u $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`
test_cleanup()
{
ggatel destroy -f -u $us
rm -f $work $src
ggatel create -u $us $work
geom_test_cleanup
}
trap test_cleanup ABRT EXIT INT TERM
dd if=${src} of=/dev/ggate${us} bs=1m count=1 >/dev/null 2>&1
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
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

View File

@ -1,31 +0,0 @@
#!/bin/sh
# $FreeBSD$
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`
ggatel create -u $us $work
dd if=${src} of=/dev/ggate${us} bs=1m count=1 >/dev/null 2>&1
if [ `cat $work | md5 -q` != $sum ]; then
echo "FAIL"
else
if [ `cat /dev/ggate${us} | md5 -q` != $sum ]; then
echo "FAIL"
else
echo "PASS"
fi
fi
ggatel destroy -u $us
mdconfig -d -u $us
mdconfig -d -u `expr $us + 1`

View File

@ -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`"
us=47
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`
test_cleanup()
{
ggatel destroy -f -u $us
ggatel create -u $us $work
geom_test_cleanup
}
trap test_cleanup ABRT EXIT INT TERM
dd if=${src} of=/dev/ggate${us} bs=1m count=1 >/dev/null 2>&1
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=/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`