diff options
author | ngie <ngie@FreeBSD.org> | 2016-01-15 02:13:55 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2016-01-15 02:13:55 +0000 |
commit | 09b006fbe78790e2d32d97d2a853f7010fbbc64e (patch) | |
tree | 39d14e1406922359f67a7bc1a3c8f7668b420aab /tools/regression | |
parent | 5c7c79a261d00bf08a9862b7c5cdeeecb97a99f9 (diff) | |
download | FreeBSD-src-09b006fbe78790e2d32d97d2a853f7010fbbc64e.zip FreeBSD-src-09b006fbe78790e2d32d97d2a853f7010fbbc64e.tar.gz |
MFC r293028,r293029:
r293028:
- Use geom <class> load instead of g<class> load; g<class> doesn't exist
for all geom classes, e.g. geom_uzip(4)
- These tests require root. Skip all of the tests if they're run as non-root
r293029:
Add functions for managing md(4) devices and cleaning up said md(4) devices
These will be used soon in the various test scripts that source geom_subr.sh
Diffstat (limited to 'tools/regression')
-rw-r--r-- | tools/regression/geom_subr.sh | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tools/regression/geom_subr.sh b/tools/regression/geom_subr.sh index 6047829..0ffb8c8 100644 --- a/tools/regression/geom_subr.sh +++ b/tools/regression/geom_subr.sh @@ -1,7 +1,12 @@ #!/bin/sh # $FreeBSD$ -kldstat -q -m g_${class} || g${class} load || exit 1 +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() { @@ -12,3 +17,32 @@ 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} +export TMPDIR +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 + + 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 +} |