From 99c1bf6f2a61e05f8d933ce0651c06e092159388 Mon Sep 17 00:00:00 2001 From: ngie Date: Sun, 13 Mar 2016 01:17:53 +0000 Subject: [PATCH] MFC r293443: - Make test-1.sh into a TAP testable testcase - Delete test-2.sh as it was an incomplete testcase, and the contents were basically a subset of test-1.sh - Add a conf.sh file for executing common functions with geom_uzip - Use attach_md for attaching md(4) devices - Don't hardcode /tmp for temporary files, which violates the kyua sandbox git-svn-id: svn://svn.freebsd.org/base/stable/10@296787 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- tools/regression/geom_uzip/Makefile | 2 +- tools/regression/geom_uzip/conf.sh | 20 ++++++++++++++ tools/regression/geom_uzip/runtests.sh | 10 ------- tools/regression/geom_uzip/test-1.sh | 36 -------------------------- tools/regression/geom_uzip/test-1.t | 22 ++++++++++++++++ tools/regression/geom_uzip/test-2.sh | 15 ----------- 6 files changed, 43 insertions(+), 62 deletions(-) create mode 100755 tools/regression/geom_uzip/conf.sh delete mode 100644 tools/regression/geom_uzip/runtests.sh delete mode 100644 tools/regression/geom_uzip/test-1.sh create mode 100644 tools/regression/geom_uzip/test-1.t delete mode 100644 tools/regression/geom_uzip/test-2.sh diff --git a/tools/regression/geom_uzip/Makefile b/tools/regression/geom_uzip/Makefile index 6927ff108..3186ef61d 100644 --- a/tools/regression/geom_uzip/Makefile +++ b/tools/regression/geom_uzip/Makefile @@ -9,7 +9,7 @@ ZIMAGE= ${IMAGE}.uzip UZIMAGE= ${ZIMAGE}.uue test: - @sh runtests.sh + prove -rv ./test-1.t image: makefs -s 1048576 ${IMAGE} etalon diff --git a/tools/regression/geom_uzip/conf.sh b/tools/regression/geom_uzip/conf.sh new file mode 100755 index 000000000..9a22841fd --- /dev/null +++ b/tools/regression/geom_uzip/conf.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD$ + +class="uzip" +base=`basename $0` + +uzip_test_cleanup() +{ + if [ -n "$mntpoint" ]; then + umount $mntpoint + rmdir $mntpoint + fi + geom_test_cleanup +} +trap uzip_test_cleanup ABRT EXIT INT TERM + +. `dirname $0`/../geom_subr.sh + +# NOTE: make sure $TMPDIR has been set by geom_subr.sh if unset [by kyua, etc] +mntpoint=$(mktemp -d tmp.XXXXXX) || exit diff --git a/tools/regression/geom_uzip/runtests.sh b/tools/regression/geom_uzip/runtests.sh deleted file mode 100644 index 60e78b540..000000000 --- a/tools/regression/geom_uzip/runtests.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -dir=`dirname $0` - -for ts in `dirname $0`/test-*.sh; do - sh $ts -done diff --git a/tools/regression/geom_uzip/test-1.sh b/tools/regression/geom_uzip/test-1.sh deleted file mode 100644 index 7e8f16840..000000000 --- a/tools/regression/geom_uzip/test-1.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -mntpoint="/mnt/test-1" - -# -# prepare -kldload geom_uzip -uudecode test-1.img.uzip.uue -num=`mdconfig -an -f test-1.img.uzip` || exit 1 -sleep 1 - -# -# mount -mkdir -p "${mntpoint}" -mount -o ro /dev/md${num}.uzip "${mntpoint}" || exit 1 - -# -# compare -#cat "${mntpoint}/etalon.txt" -diff -u etalon/etalon.txt "${mntpoint}/etalon.txt" -if [ $? -eq 0 ]; then - echo "PASS" -else - echo "FAIL" -fi - -# -# cleanup -umount "${mntpoint}" -rmdir "${mntpoint}" -mdconfig -d -u ${num} -sleep 1 -kldunload geom_uzip diff --git a/tools/regression/geom_uzip/test-1.t b/tools/regression/geom_uzip/test-1.t new file mode 100644 index 000000000..b156c0674 --- /dev/null +++ b/tools/regression/geom_uzip/test-1.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD$ + +testsdir=$(dirname $0) +. $testsdir/conf.sh + +echo "1..1" + +UUE=$testsdir/test-1.img.uzip.uue +uudecode $UUE +us0=$(attach_md -f $(basename $UUE .uue)) || exit 1 +sleep 1 + +mount -o ro /dev/${us0}.uzip "${mntpoint}" || exit 1 + +#cat "${mntpoint}/etalon.txt" +diff -I '\$FreeBSD.*\$' -u $testsdir/etalon/etalon.txt "${mntpoint}/etalon.txt" +if [ $? -eq 0 ]; then + echo "ok 1" +else + echo "not ok 1" +fi diff --git a/tools/regression/geom_uzip/test-2.sh b/tools/regression/geom_uzip/test-2.sh deleted file mode 100644 index 866282753..000000000 --- a/tools/regression/geom_uzip/test-2.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -# -# prepare -kldload geom_uzip -uudecode test-1.img.uzip.uue -num=`mdconfig -an -f test-1.img.uzip` || exit 1 -sleep 1 - -# -# destroy -kldunload geom_uzip -- 2.45.0