diff options
author | ngie <ngie@FreeBSD.org> | 2016-01-22 07:23:50 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2016-01-22 07:23:50 +0000 |
commit | 7a67cba86b1ced9982ebb0dd11a9a987829efe9e (patch) | |
tree | 39f3a5b9f661dddf5d6a63b762f63fd41533f75d /tools | |
parent | 1781e96ea4695a84ebe3036292a7e649efae3e59 (diff) | |
download | FreeBSD-src-7a67cba86b1ced9982ebb0dd11a9a987829efe9e.zip FreeBSD-src-7a67cba86b1ced9982ebb0dd11a9a987829efe9e.tar.gz |
MFC r293048,r293444:
r293048:
- Use a temporary file for the temporary md(4) devices instead of
hardcoding it
- Remove the temporary file in the cleanup routine
r293444:
- Move functions that might be used in class-specific cleanup functions
(geom_test_cleanup, etc) down so the testcases don't emit noise when
bailing
- Conform to the TAP protocol better when dealing with classes that can't
be loaded and with temporary files that can't be allocated for tracking
md(4) devices.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/geom_subr.sh | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/tools/regression/geom_subr.sh b/tools/regression/geom_subr.sh index 0ffb8c8..b437183 100644 --- a/tools/regression/geom_subr.sh +++ b/tools/regression/geom_subr.sh @@ -1,13 +1,6 @@ #!/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} || geom ${class} load || exit 1 - devwait() { while :; do @@ -18,13 +11,6 @@ devwait() 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} -export TMPDIR -TEST_MDS_FILE=${TMPDIR}/test_mds - attach_md() { local test_md @@ -38,11 +24,37 @@ geom_test_cleanup() { local test_md - if [ -f $TEST_MDS_FILE ]; then + if [ -f "$TEST_MDS_FILE" ]; then 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 fi + rm -f "$TEST_MDS_FILE" } + +if [ $(id -u) -ne 0 ]; then + echo 'Tests must be run as root' + echo 'Bail out!' + exit 1 +fi +# If the geom class isn't already loaded, try loading it. +if ! kldstat -q -m g_${class}; then + if ! geom ${class} load; then + echo "Could not load module for geom class=${class}" + echo 'Bail out!' + exit 1 + fi +fi + +# 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} +export TMPDIR +if ! TEST_MDS_FILE=$(mktemp ${TMPDIR}/test_mds.XXXXXX); then + echo 'Failed to create temporary file for tracking the test md(4) devices' + echo 'Bail out!' + exit 1 +fi |