Date: Mon, 16 Nov 2015 21:50:03 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r290949 - user/ngie/more-tests2/sbin/geom/class/tests Message-ID: <201511162150.tAGLo37d066145@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Mon Nov 16 21:50:02 2015 New Revision: 290949 URL: https://svnweb.freebsd.org/changeset/base/290949 Log: - Check for root; all of these tests will fail if not root - Add attach_md/geom_test_cleanup functions to deal with the fact that many of the tests caused issues if one of the preceding tests failed (sometimes due to a test time out), which would cause a cascade of other erroneous failures due to hardcoded md(4) device names. Modified: user/ngie/more-tests2/sbin/geom/class/tests/geom_subr.sh Modified: user/ngie/more-tests2/sbin/geom/class/tests/geom_subr.sh ============================================================================== --- user/ngie/more-tests2/sbin/geom/class/tests/geom_subr.sh Mon Nov 16 21:36:50 2015 (r290948) +++ user/ngie/more-tests2/sbin/geom/class/tests/geom_subr.sh Mon Nov 16 21:50:02 2015 (r290949) @@ -1,6 +1,11 @@ #!/bin/sh # $FreeBSD$ +if [ $(id -u) -ne 0 ]; then + echo 'Tests must be run as root' + echo 'Bail out!' + exit 1 +fi kldstat -q -m g_${class} || g${class} load || exit 1 devwait() @@ -12,3 +17,29 @@ devwait() sleep 0.2 done } + +# Need to keep track of the test md devices to avoid the scenario where a test +# failing will cause the other tests to bomb out, or a test failing will leave +# a large number of md(4) devices lingering around +: ${TMPDIR=/tmp} +TEST_MDS_FILE=${TMPDIR}/test_mds + +attach_md() +{ + local test_md + + test_md=$(mdconfig -a "$@") || exit + echo $test_md >> $TEST_MDS_FILE || exit + echo $test_md +} + +geom_test_cleanup() +{ + local test_md + + while read test_md; do + # The "#" tells the TAP parser this is a comment + echo "# Removing test memory disk: $test_md" + mdconfig -d -u $test_md + done < $TEST_MDS_FILE +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511162150.tAGLo37d066145>