summaryrefslogtreecommitdiffstats
path: root/tools/regression
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-01-01 02:25:10 +0000
committerngie <ngie@FreeBSD.org>2016-01-01 02:25:10 +0000
commitb8e70bf7efef670381034d0f5a8ded060def0121 (patch)
treee66cc71268ee70e8b642260160acd8b367ec17f0 /tools/regression
parente1ad05666fed2d75bd83515fa1c336daf0de9a33 (diff)
downloadFreeBSD-src-b8e70bf7efef670381034d0f5a8ded060def0121.zip
FreeBSD-src-b8e70bf7efef670381034d0f5a8ded060def0121.tar.gz
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 MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'tools/regression')
-rw-r--r--tools/regression/geom_subr.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/regression/geom_subr.sh b/tools/regression/geom_subr.sh
index 8bc69c6..0ffb8c8 100644
--- a/tools/regression/geom_subr.sh
+++ b/tools/regression/geom_subr.sh
@@ -17,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
+}
OpenPOWER on IntegriCloud