Deleted Added
full compact
geom_subr.sh (293048) geom_subr.sh (293444)
1#!/bin/sh
1#!/bin/sh
2# $FreeBSD: head/tools/regression/geom_subr.sh 293048 2016-01-02 10:07:31Z ngie $
2# $FreeBSD: head/tools/regression/geom_subr.sh 293444 2016-01-08 21:47:41Z ngie $
3
3
4if [ $(id -u) -ne 0 ]; then
5 echo 'Tests must be run as root'
6 echo 'Bail out!'
7 exit 1
8fi
9kldstat -q -m g_${class} || geom ${class} load || exit 1
10
11devwait()
12{
13 while :; do
14 if [ -c /dev/${class}/${name} ]; then
15 return
16 fi
17 sleep 0.2
18 done
19}
20
4devwait()
5{
6 while :; do
7 if [ -c /dev/${class}/${name} ]; then
8 return
9 fi
10 sleep 0.2
11 done
12}
13
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}
25export TMPDIR
26TEST_MDS_FILE=$(mktemp ${TMPDIR}/test_mds.XXXXXX) || exit 1
27
28attach_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
37geom_test_cleanup()
38{
39 local test_md
40
14attach_md()
15{
16 local test_md
17
18 test_md=$(mdconfig -a "$@") || exit
19 echo $test_md >> $TEST_MDS_FILE || exit
20 echo $test_md
21}
22
23geom_test_cleanup()
24{
25 local test_md
26
41 if [ -f $TEST_MDS_FILE ]; then
27 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
28 while read test_md; do
29 # The "#" tells the TAP parser this is a comment
30 echo "# Removing test memory disk: $test_md"
31 mdconfig -d -u $test_md
32 done < $TEST_MDS_FILE
33 fi
48 rm -f $TEST_MDS_FILE
34 rm -f "$TEST_MDS_FILE"
49}
35}
36
37if [ $(id -u) -ne 0 ]; then
38 echo 'Tests must be run as root'
39 echo 'Bail out!'
40 exit 1
41fi
42# If the geom class isn't already loaded, try loading it.
43if ! kldstat -q -m g_${class}; then
44 if ! geom ${class} load; then
45 echo "Could not load module for geom class=${class}"
46 echo 'Bail out!'
47 exit 1
48 fi
49fi
50
51# Need to keep track of the test md devices to avoid the scenario where a test
52# failing will cause the other tests to bomb out, or a test failing will leave
53# a large number of md(4) devices lingering around
54: ${TMPDIR=/tmp}
55export TMPDIR
56if ! TEST_MDS_FILE=$(mktemp ${TMPDIR}/test_mds.XXXXXX); then
57 echo 'Failed to create temporary file for tracking the test md(4) devices'
58 echo 'Bail out!'
59 exit 1
60fi