Index: tests/sys/geom/class/nop/1_test.sh =================================================================== --- tests/sys/geom/class/nop/1_test.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -. `dirname $0`/conf.sh - -echo "1..1" - -us=$(attach_md -t malloc -s 1M) || exit 1 - -gnop create /dev/${us} || exit 1 - -# Size of created device should be 1MB. - -size=`diskinfo /dev/${us}.nop | awk '{print $3}'` - -if [ $size -eq 1048576 ]; then - echo "ok 1" -else - echo "not ok 1" -fi Index: tests/sys/geom/class/nop/2_test.sh =================================================================== --- tests/sys/geom/class/nop/2_test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -. `dirname $0`/conf.sh - -src=`mktemp $base.XXXXXX` || exit 1 -dst=`mktemp $base.XXXXXX` || exit 1 - -echo "1..1" - -dd if=/dev/random of=${src} bs=1m count=1 >/dev/null 2>&1 - -us=$(attach_md -t malloc -s 1M) || exit 1 - -gnop create /dev/${us} || exit 1 - -dd if=${src} of=/dev/${us}.nop bs=1m count=1 >/dev/null 2>&1 -dd if=/dev/${us}.nop of=${dst} bs=1m count=1 >/dev/null 2>&1 - -if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then - echo "not ok 1" -else - echo "ok 1" -fi - -rm -f ${src} ${dst} Index: tests/sys/geom/class/nop/Makefile =================================================================== --- tests/sys/geom/class/nop/Makefile +++ tests/sys/geom/class/nop/Makefile @@ -4,13 +4,6 @@ TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T} -TAP_TESTS_SH+= 1_test -TAP_TESTS_SH+= 2_test - -${PACKAGE}FILES+= conf.sh - -.for t in ${TAP_TESTS_SH} -TEST_METADATA.$t+= required_user="root" -.endfor +ATF_TESTS_SH+= nop_test .include Index: tests/sys/geom/class/nop/conf.sh =================================================================== --- tests/sys/geom/class/nop/conf.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# $FreeBSD$ - -class="nop" -base=`basename $0` - -gnop_test_cleanup() -{ - [ -c /dev/${us}.nop ] && gnop destroy ${us}.nop - geom_test_cleanup -} -trap gnop_test_cleanup ABRT EXIT INT TERM - -. `dirname $0`/../geom_subr.sh Index: tests/sys/geom/class/nop/nop_test.sh =================================================================== --- /dev/null +++ tests/sys/geom/class/nop/nop_test.sh @@ -0,0 +1,147 @@ +# $FreeBSD$ + +MD_DEVS="md.devs" +PLAINFILES=plainfiles + +atf_test_case diskinfo cleanup +diskinfo_head() +{ + atf_set "descr" "gnop should preserve diskinfo's basic properties" + atf_set "require.user" "root" + atf_set "timeout" 15 +} +diskinfo_body() +{ + us=$(alloc_md) + atf_check gnop create /dev/${us} + md_secsize=$(diskinfo ${us} | cut -wf 2) + md_mediasize=$(diskinfo ${us} | cut -wf 3) + md_stripesize=$(diskinfo ${us} | cut -wf 5) + nop_secsize=$(diskinfo ${us}.nop | cut -wf 2) + nop_mediasize=$(diskinfo ${us}.nop | cut -wf 3) + nop_stripesize=$(diskinfo ${us}.nop | cut -wf 5) + atf_check [ "$md_secsize" -eq "$nop_secsize" ] + atf_check [ "$md_mediasize" -eq "$nop_mediasize" ] + atf_check [ "$md_stripesize" -eq "$nop_stripesize" ] +} +diskinfo_cleanup() +{ + common_cleanup +} + +atf_test_case io cleanup +io_head() +{ + atf_set "descr" "I/O works on gnop devices" + atf_set "require.user" "root" + atf_set "timeout" 15 +} +io_body() +{ + us=$(alloc_md) + atf_check gnop create /dev/${us} + + echo src >> $PLAINFILES + echo dst >> $PLAINFILES + dd if=/dev/random of=src bs=1m count=1 >/dev/null 2>&1 + dd if=src of=/dev/${us}.nop bs=1m count=1 > /dev/null 2>&1 + dd if=/dev/${us}.nop of=dst bs=1m count=1 > /dev/null 2>&1 + + if [ `md5 -q src` != `md5 -q dst` ]; then + echo "not ok 1" + else + echo "ok 1" + fi +} +io_cleanup() +{ + common_cleanup +} + +atf_test_case size cleanup +size_head() +{ + atf_set "descr" "Test gnop's -s option" + atf_set "require.user" "root" + atf_set "timeout" 15 +} +size_body() +{ + us=$(alloc_md) + for mediasize in 65536 524288 1048576; do + atf_check gnop create -s ${mediasize} /dev/${us} + gnop_mediasize=`diskinfo /dev/${us}.nop | cut -wf 3` + atf_check [ "${mediasize}" -eq "${gnop_mediasize}" ] + atf_check gnop destroy /dev/${us}.nop + done + # We shouldn't be able to extend the provider's size + atf_check -s exit:1 -e ignore gnop create -s 2097152 /dev/${us} +} +size_cleanup() +{ + common_cleanup +} + +atf_test_case stripesize cleanup +stripesize_head() +{ + atf_set "descr" "Test gnop's -p and -P options" + atf_set "require.user" "root" + atf_set "timeout" 15 +} +stripesize_body() +{ + us=$(alloc_md) + for ss in 512 1024 2048 4096 8192; do + for sofs in `seq 0 512 ${ss}`; do + [ "$sofs" -eq "$ss" ] && continue + atf_check gnop create -p ${ss} -P ${sofs} /dev/${us} + gnop_ss=`diskinfo /dev/${us}.nop | cut -wf 5` + gnop_sofs=`diskinfo /dev/${us}.nop | cut -wf 6` + atf_check [ "${ss}" -eq "${gnop_ss}" ] + atf_check [ "${sofs}" -eq "${gnop_sofs}" ] + atf_check gnop destroy /dev/${us}.nop + done + done +} +stripesize_cleanup() +{ + common_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case io + atf_add_test_case diskinfo + atf_add_test_case stripesize + atf_add_test_case size +} + +alloc_md() +{ + local md + + md=$(mdconfig -a -t swap -s 1M) || atf_fail "mdconfig -a failed" + echo ${md} >> $MD_DEVS + echo ${md} +} + +common_cleanup() +{ + if [ -f "$MD_DEVS" ]; then + while read test_md; do + gnop destroy -f ${test_md}.nop 2>/dev/null + mdconfig -d -u $test_md 2>/dev/null + done < $MD_DEVS + rm $MD_DEVS + fi + + if [ -f "$PLAINFILES" ]; then + while read f; do + rm -f ${f} + done < ${PLAINFILES} + rm ${PLAINFILES} + fi + true +} +