summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ObsoleteFiles.inc5
-rw-r--r--tests/sys/geom/class/gate/1_test.sh63
-rw-r--r--tests/sys/geom/class/gate/2_test.sh48
-rw-r--r--tests/sys/geom/class/gate/3_test.sh49
-rw-r--r--tests/sys/geom/class/gate/Makefile10
-rwxr-xr-xtests/sys/geom/class/gate/conf.sh8
-rwxr-xr-xtests/sys/geom/class/gate/ggate_test.sh207
7 files changed, 213 insertions, 177 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index cf82445..70b4a34 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -38,6 +38,11 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20170214: Four files from ggate tests consolidated into one
+OLD_FILES+=usr/tests/sys/geom/class/gate/1_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/2_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/3_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/conf.sh
# 20170211: libarchive ACL pax test renamed to test_acl_pax_posix1e.tar.uu
OLD_FILES+=usr/tests/lib/libarchive/test_acl_pax.tar.uu
# 20170103: libbsnmptools.so made into an INTERNALLIB
diff --git a/tests/sys/geom/class/gate/1_test.sh b/tests/sys/geom/class/gate/1_test.sh
deleted file mode 100644
index ba573bb..0000000
--- a/tests/sys/geom/class/gate/1_test.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-# $FreeBSD$
-
-. `dirname $0`/conf.sh
-
-echo '1..2'
-
-base=`basename $0`
-us=0
-while [ -c /dev/ggate${us} ]; do
- : $(( us += 1 ))
-done
-pidfile=ggated.$$.pid
-conf=`mktemp $base.XXXXXX` || exit 1
-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 -F $pidfile $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
-sleep 1
-
-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'
-
- 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
deleted file mode 100644
index be89acc..0000000
--- a/tests/sys/geom/class/gate/2_test.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/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
deleted file mode 100644
index 3511df7..0000000
--- a/tests/sys/geom/class/gate/3_test.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/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
-
-sleep 1
-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
index c034bf0..417fa7d 100644
--- a/tests/sys/geom/class/gate/Makefile
+++ b/tests/sys/geom/class/gate/Makefile
@@ -4,14 +4,6 @@ PACKAGE= tests
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
-TAP_TESTS_SH+= 1_test
-TAP_TESTS_SH+= 2_test
-TAP_TESTS_SH+= 3_test
-
-${PACKAGE}FILES+= conf.sh
-
-.for t in ${TAP_TESTS_SH}
-TEST_METADATA.$t+= required_user="root"
-.endfor
+ATF_TESTS_SH+= ggate_test
.include <bsd.test.mk>
diff --git a/tests/sys/geom/class/gate/conf.sh b/tests/sys/geom/class/gate/conf.sh
deleted file mode 100755
index 7e22ce4..0000000
--- a/tests/sys/geom/class/gate/conf.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# $FreeBSD$
-
-name="$(mktemp -u gate.XXXXXX)"
-class="gate"
-base=`basename $0`
-
-. `dirname $0`/../geom_subr.sh
diff --git a/tests/sys/geom/class/gate/ggate_test.sh b/tests/sys/geom/class/gate/ggate_test.sh
new file mode 100755
index 0000000..162744d
--- /dev/null
+++ b/tests/sys/geom/class/gate/ggate_test.sh
@@ -0,0 +1,207 @@
+# $FreeBSD$
+
+PIDFILE=ggated.pid
+PLAINFILES=plainfiles
+PORT=33080
+CONF=gg.exports
+
+atf_test_case ggated cleanup
+ggated_head()
+{
+ atf_set "descr" "ggated can proxy geoms"
+ atf_set "require.progs" "ggatec ggated"
+ atf_set "require.user" "root"
+ atf_set "timeout" 60
+}
+
+ggated_body()
+{
+ us=$(alloc_ggate_dev)
+ work=$(alloc_md)
+ src=$(alloc_md)
+
+ atf_check -e ignore -o ignore \
+ dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc
+ atf_check -e ignore -o ignore \
+ dd if=/dev/random of=/dev/$src bs=1m count=1 conv=notrunc
+
+ echo $CONF >> $PLAINFILES
+ echo "127.0.0.1 RW /dev/$work" > $CONF
+
+ atf_check ggated -p $PORT -F $PIDFILE $CONF
+ atf_check ggatec create -p $PORT -u $us 127.0.0.1 /dev/$work
+
+ ggate_dev=/dev/ggate${us}
+
+ wait_for_ggate_device ${ggate_dev}
+
+ atf_check -e ignore -o ignore \
+ dd if=/dev/${src} of=${ggate_dev} bs=1m count=1 conv=notrunc
+
+ checksum /dev/$src /dev/$work
+}
+
+ggated_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case ggatel_file cleanup
+ggatel_file_head()
+{
+ atf_set "descr" "ggatel can proxy files"
+ atf_set "require.progs" "ggatel"
+ atf_set "require.user" "root"
+ atf_set "timeout" 15
+}
+
+ggatel_file_body()
+{
+ us=$(alloc_ggate_dev)
+
+ echo src work >> ${PLAINFILES}
+ dd if=/dev/random of=work bs=1m count=1
+ dd if=/dev/random of=src bs=1m count=1
+
+ atf_check ggatel create -u $us work
+
+ ggate_dev=/dev/ggate${us}
+
+ wait_for_ggate_device ${ggate_dev}
+
+ atf_check -e ignore -o ignore \
+ dd if=src of=${ggate_dev} bs=1m count=1 conv=notrunc
+
+ checksum src work
+}
+
+ggatel_file_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case ggatel_md cleanup
+ggatel_md_head()
+{
+ atf_set "descr" "ggatel can proxy files"
+ atf_set "require.progs" "ggatel"
+ atf_set "require.user" "root"
+ atf_set "timeout" 15
+}
+
+ggatel_md_body()
+{
+ us=$(alloc_ggate_dev)
+ work=$(alloc_md)
+ src=$(alloc_md)
+
+ atf_check -e ignore -o ignore \
+ dd if=/dev/random of=$work bs=1m count=1 conv=notrunc
+ atf_check -e ignore -o ignore \
+ dd if=/dev/random of=$src bs=1m count=1 conv=notrunc
+
+ atf_check ggatel create -u $us /dev/$work
+
+ ggate_dev=/dev/ggate${us}
+
+ wait_for_ggate_device ${ggate_dev}
+
+ atf_check -e ignore -o ignore \
+ dd if=/dev/$src of=${ggate_dev} bs=1m count=1 conv=notrunc
+
+ checksum /dev/$src /dev/$work
+}
+
+ggatel_md_cleanup()
+{
+ common_cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case ggated
+ atf_add_test_case ggatel_file
+ atf_add_test_case ggatel_md
+}
+
+alloc_ggate_dev()
+{
+ local us
+
+ us=0
+ while [ -c /dev/ggate${us} ]; do
+ : $(( us += 1 ))
+ done
+ echo ${us} > ggate.devs
+ echo ${us}
+}
+
+alloc_md()
+{
+ local md
+
+ md=$(mdconfig -a -t malloc -s 1M) || \
+ atf_fail "failed to allocate md device"
+ echo ${md} >> md.devs
+ echo ${md}
+}
+
+checksum()
+{
+ local src work
+ src=$1
+ work=$2
+
+ src_checksum=$(md5 -q $src)
+ work_checksum=$(md5 -q $work)
+
+ if [ "$work_checksum" != "$src_checksum" ]; then
+ atf_fail "work md5 checksum didn't match"
+ fi
+
+ ggate_checksum=$(md5 -q /dev/ggate${us})
+ if [ "$ggate_checksum" != "$src_checksum" ]; then
+ atf_fail "ggate md5 checksum didn't match"
+ fi
+}
+
+common_cleanup()
+{
+ if [ -f "ggate.devs" ]; then
+ while read test_ggate; do
+ ggatec destroy -f -u $test_ggate >/dev/null
+ done < ggate.devs
+ rm ggate.devs
+ fi
+
+ if [ -f "$PIDFILE" ]; then
+ pkill -F "$PIDFILE"
+ rm $PIDFILE
+ fi
+
+ if [ -f "PLAINFILES" ]; then
+ while read f; do
+ rm -f ${f}
+ done < ${PLAINFILES}
+ rm ${PLAINFILES}
+ fi
+
+ if [ -f "md.devs" ]; then
+ while read test_md; do
+ mdconfig -d -u $test_md 2>/dev/null
+ done < md.devs
+ rm md.devs
+ fi
+ true
+}
+
+# Bug 204616: ggatel(8) creates /dev/ggate* asynchronously if `ggatel create`
+# isn't called with `-v`.
+wait_for_ggate_device()
+{
+ ggate_device=$1
+
+ while [ ! -c $ggate_device ]; do
+ sleep 0.5
+ done
+}
OpenPOWER on IntegriCloud