mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-30 21:43:34 +00:00
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
This commit is contained in:
parent
4982dca18d
commit
9a1fe327ae
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311893
@ -38,6 +38,11 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20170110: 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
|
||||
# 20170103: libbsnmptools.so made into an INTERNALLIB
|
||||
OLD_FILES+=usr/lib/libbsnmptools.a
|
||||
OLD_FILES+=usr/lib/libbsnmptools_p.a
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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>
|
||||
|
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
name="$(mktemp -u gate.XXXXXX)"
|
||||
class="gate"
|
||||
base=`basename $0`
|
||||
|
||||
. `dirname $0`/../geom_subr.sh
|
193
tests/sys/geom/class/gate/ggate_test.sh
Executable file
193
tests/sys/geom/class/gate/ggate_test.sh
Executable file
@ -0,0 +1,193 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PIDFILE=ggated.pid
|
||||
PLAINFILES=plainfiles
|
||||
PORT=33080
|
||||
CONF=gg.exports
|
||||
RETRIES=16
|
||||
|
||||
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)
|
||||
|
||||
dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc
|
||||
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
|
||||
for try in `jot $RETRIES`; do
|
||||
ggatec create -p $PORT -u $us 127.0.0.1 /dev/$work && break
|
||||
# wait for ggated to be ready
|
||||
sleep 0.25
|
||||
done
|
||||
if [ "$try" -eq "$RETRIES" ]; then
|
||||
atf_fail "ggatec create failed"
|
||||
fi
|
||||
|
||||
for try in `jot $RETRIES`; do
|
||||
dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1 conv=notrunc\
|
||||
&& break
|
||||
# Wait for /dev/ggate${us} to be ready
|
||||
sleep 0.25
|
||||
done
|
||||
if [ "$try" -eq "$RETRIES" ]; then
|
||||
atf_fail "dd failed; /dev/ggate${us} isn't working"
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
dd if=src of=/dev/ggate${us} 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)
|
||||
|
||||
dd if=/dev/random of=$work bs=1m count=1 conv=notrunc
|
||||
dd if=/dev/random of=$src bs=1m count=1 conv=notrunc
|
||||
|
||||
atf_check ggatel create -u $us /dev/$work
|
||||
|
||||
dd if=/dev/$src of=/dev/ggate${us} 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user