From a50007a155e7fbf5abe60669584a22ff31f09fa8 Mon Sep 17 00:00:00 2001 From: ngie Date: Fri, 1 Jan 2016 00:12:10 +0000 Subject: Move sbin/geom/class/tests to tests/sys/geom/class and remove sbin/geom/tests This is inspired by parallel efforts being done on projects/zfsd (and makes more sense because these are functional tests of the subsystems, not the geom(8) commands --- tests/sys/geom/class/gate/1_test.sh | 61 +++++++++++++++++++++++++++++++++++++ tests/sys/geom/class/gate/2_test.sh | 48 +++++++++++++++++++++++++++++ tests/sys/geom/class/gate/3_test.sh | 48 +++++++++++++++++++++++++++++ tests/sys/geom/class/gate/Makefile | 11 +++++++ tests/sys/geom/class/gate/conf.sh | 10 ++++++ 5 files changed, 178 insertions(+) create mode 100755 tests/sys/geom/class/gate/1_test.sh create mode 100755 tests/sys/geom/class/gate/2_test.sh create mode 100755 tests/sys/geom/class/gate/3_test.sh create mode 100644 tests/sys/geom/class/gate/Makefile create mode 100755 tests/sys/geom/class/gate/conf.sh (limited to 'tests/sys/geom/class/gate') diff --git a/tests/sys/geom/class/gate/1_test.sh b/tests/sys/geom/class/gate/1_test.sh new file mode 100755 index 0000000..fb6fd62 --- /dev/null +++ b/tests/sys/geom/class/gate/1_test.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# $FreeBSD$ + +. `dirname $0`/conf.sh + +base=`basename $0` +us=0 +while [ -c /dev/ggate${us} ]; do + : $(( us += 1 )) +done +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 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 -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=/dev/${src} of=/dev/ggate${us} bs=1m count=1 +sleep 1 + +echo '1..2' + +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' + + 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 diff --git a/tests/sys/geom/class/gate/2_test.sh b/tests/sys/geom/class/gate/2_test.sh new file mode 100755 index 0000000..be89acc --- /dev/null +++ b/tests/sys/geom/class/gate/2_test.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# $FreeBSD$ + +. `dirname $0`/conf.sh + +base=`basename $0` +us=46 +work=`mktemp -u $base.XXXXXX` || exit 1 +src=`mktemp -u $base.XXXXXX` || exit 1 + +test_cleanup() +{ + ggatel destroy -f -u $us + rm -f $work $src + + geom_test_cleanup +} +trap test_cleanup ABRT EXIT INT TERM + +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' + +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' + + 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 diff --git a/tests/sys/geom/class/gate/3_test.sh b/tests/sys/geom/class/gate/3_test.sh new file mode 100755 index 0000000..8901aca --- /dev/null +++ b/tests/sys/geom/class/gate/3_test.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# $FreeBSD$ + +. `dirname $0`/conf.sh + +base=`basename $0` +us=47 + +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 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' + +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' + + 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 diff --git a/tests/sys/geom/class/gate/Makefile b/tests/sys/geom/class/gate/Makefile new file mode 100644 index 0000000..985d98f --- /dev/null +++ b/tests/sys/geom/class/gate/Makefile @@ -0,0 +1,11 @@ +# $FreeBSD$ + +TAP_TESTS_SH+= 1_test +TAP_TESTS_SH+= 2_test +TAP_TESTS_SH+= 3_test + +FILES+= conf.sh +FILESNAME_conf.sh= conf.sh +FILESDIR= ${TESTSDIR} + +.include diff --git a/tests/sys/geom/class/gate/conf.sh b/tests/sys/geom/class/gate/conf.sh new file mode 100755 index 0000000..4eede08 --- /dev/null +++ b/tests/sys/geom/class/gate/conf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# $FreeBSD$ + +name="$(mktemp -u gate.XXXXXX)" +class="gate" +base=`basename $0` + +kldstat -q -m g_${class} || kldload geom_${class} || exit 1 + +. `dirname $0`/../geom_subr.sh -- cgit v1.1