summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2017-02-15 00:16:52 +0000
committerasomers <asomers@FreeBSD.org>2017-02-15 00:16:52 +0000
commit50ab11fce02e8a54c23784af5e534a8084b374d6 (patch)
tree1d8bd3880d4700c706eb2e6e2536c1a054714030 /tests
parentfafa7b31df860d1913826def1e1342e032042399 (diff)
downloadFreeBSD-src-50ab11fce02e8a54c23784af5e534a8084b374d6.zip
FreeBSD-src-50ab11fce02e8a54c23784af5e534a8084b374d6.tar.gz
MFC r311893, r313008, r313081
I had to modify the tests slightly for the MFC to stable/10, because stable/10 lacks r294037, which enabled /sbin/md5 to work on md(4) devices. r311893: ATFify the geom gate tests. This ensures their cleanup routines will be run even if they should timeout. tests/sys/geom/class/gate/ggate_test.sh tests/sys/geom/class/gate/Makefile Add an ATF test with three testcases, one for each TAP test. Use ATF-style cleanup functions, and convert sleeps to polling loops. ObsoleteFiles.inc tests/sys/geom/class/gate/conf.sh tests/sys/geom/class/gate/1_test.sh tests/sys/geom/class/gate/2_test.sh tests/sys/geom/class/gate/3_test.sh Delete TAP test files Reviewed by: ngie MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8891 r313008: Wait for /dev/ggate* to appear after calling `ggatel create` in :ggatel_{file,md} The test assumed that `ggatel create` created a device on completion, but that's incorrect. This squashes the race by waiting for the device to appear, as `ggatel create` daemonizes before issuing an ioctl to geom_gate(4) if not called with `-v`. Discussed with: asomers MFC after: 1 week PR: 204616 Sponsored by: Dell EMC Isilon r313081: Replace for/retry loops with "wait_for_ggate_device" calls and check results of commands As noted in r313008, the underlying issue was that geom_gate device creation wasn't created at ggatel command completion, but some short time after. ggatec(8) employs similar logic when creating geom_gate(4) devices. Switch from retry loops (after the ggatec/dd write calls) to wait_for_ggate_device function calls after calling ggatec(8) instead to detect the presence of the /dev/ggate* device, as this function is sufficient for determining whether or not the character device is ready for testing While here, use atf_check consistently with all dd calls to ensure that data output is as expected. MFC after: 1 week Reviewed by: asomers Differential Revision: D9409 Sponsored by: Dell EMC Isilon
Diffstat (limited to 'tests')
-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/Makefile12
-rwxr-xr-xtests/sys/geom/class/gate/conf.sh8
-rwxr-xr-xtests/sys/geom/class/gate/ggate_test.sh207
6 files changed, 208 insertions, 179 deletions
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 11ceb94..0b84248 100644
--- a/tests/sys/geom/class/gate/Makefile
+++ b/tests/sys/geom/class/gate/Makefile
@@ -2,16 +2,6 @@
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
-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}
-
-.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..18b4214
--- /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=$(dd if=${src} bs=1m | md5 -q)
+ work_checksum=$(dd if=${work} bs=1m | md5 -q)
+
+ if [ "$work_checksum" != "$src_checksum" ]; then
+ atf_fail "work md5 checksum didn't match"
+ fi
+
+ ggate_checksum=$(dd if=/dev/ggate${us} bs=1m | md5 -q)
+ 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