]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - tools/regression/geom_subr.sh
MFC r293028,r293029:
[FreeBSD/stable/10.git] / tools / regression / geom_subr.sh
1 #!/bin/sh
2 # $FreeBSD$
3
4 if [ $(id -u) -ne 0 ]; then
5         echo 'Tests must be run as root'
6         echo 'Bail out!'
7         exit 1
8 fi
9 kldstat -q -m g_${class} || geom ${class} load || exit 1
10
11 devwait()
12 {
13         while :; do
14                 if [ -c /dev/${class}/${name} ]; then
15                         return
16                 fi
17                 sleep 0.2
18         done
19 }
20
21 # Need to keep track of the test md devices to avoid the scenario where a test
22 # failing will cause the other tests to bomb out, or a test failing will leave
23 # a large number of md(4) devices lingering around
24 : ${TMPDIR=/tmp}
25 export TMPDIR
26 TEST_MDS_FILE=${TMPDIR}/test_mds
27
28 attach_md()
29 {
30         local test_md
31
32         test_md=$(mdconfig -a "$@") || exit
33         echo $test_md >> $TEST_MDS_FILE || exit
34         echo $test_md
35 }
36
37 geom_test_cleanup()
38 {
39         local test_md
40
41         if [ -f $TEST_MDS_FILE ]; then
42                 while read test_md; do
43                         # The "#" tells the TAP parser this is a comment
44                         echo "# Removing test memory disk: $test_md"
45                         mdconfig -d -u $test_md
46                 done < $TEST_MDS_FILE
47         fi
48 }