2005-12-07 01:20:18 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# $FreeBSD$
|
|
|
|
|
2018-12-07 00:27:38 +00:00
|
|
|
TEST_MDS_FILE="${TMPDIR}/test_mds.$(basename $0)"
|
2018-12-02 05:06:37 +00:00
|
|
|
|
2005-12-07 01:20:18 +00:00
|
|
|
devwait()
|
|
|
|
{
|
|
|
|
while :; do
|
|
|
|
if [ -c /dev/${class}/${name} ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
sleep 0.2
|
|
|
|
done
|
|
|
|
}
|
2016-01-01 02:25:10 +00:00
|
|
|
|
|
|
|
attach_md()
|
|
|
|
{
|
|
|
|
local test_md
|
|
|
|
|
|
|
|
test_md=$(mdconfig -a "$@") || exit
|
|
|
|
echo $test_md >> $TEST_MDS_FILE || exit
|
|
|
|
echo $test_md
|
|
|
|
}
|
|
|
|
|
2017-12-14 22:11:35 +00:00
|
|
|
detach_md()
|
|
|
|
{
|
|
|
|
local test_md unit
|
|
|
|
|
|
|
|
test_md=$1
|
|
|
|
unit=${test_md#md}
|
|
|
|
mdconfig -d -u $unit || exit
|
|
|
|
sed -i '' "/^${test_md}$/d" $TEST_MDS_FILE || exit
|
|
|
|
}
|
|
|
|
|
2016-01-01 02:25:10 +00:00
|
|
|
geom_test_cleanup()
|
|
|
|
{
|
|
|
|
local test_md
|
|
|
|
|
2016-01-08 21:47:41 +00:00
|
|
|
if [ -f "$TEST_MDS_FILE" ]; then
|
2016-01-01 02:25:10 +00:00
|
|
|
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
|
2018-12-02 05:06:37 +00:00
|
|
|
rm -f "$TEST_MDS_FILE"
|
2016-01-01 02:25:10 +00:00
|
|
|
fi
|
|
|
|
}
|
2016-01-08 21:47:41 +00:00
|
|
|
|
2018-12-02 05:06:37 +00:00
|
|
|
geom_load_class_if_needed()
|
|
|
|
{
|
|
|
|
local class=$1
|
|
|
|
|
|
|
|
# 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}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
geom_atf_test_setup()
|
|
|
|
{
|
|
|
|
if ! error_message=$(geom_load_class_if_needed $class); then
|
|
|
|
atf_skip "$error_message"
|
|
|
|
fi
|
|
|
|
}
|
2017-12-14 22:11:35 +00:00
|
|
|
|
2018-12-02 05:06:37 +00:00
|
|
|
geom_tap_test_setup()
|
|
|
|
{
|
|
|
|
if ! error_message=$(geom_load_class_if_needed $class); then
|
|
|
|
echo "1..0 # SKIP $error_message"
|
2016-03-22 08:12:45 +00:00
|
|
|
exit 0
|
2016-01-08 21:47:41 +00:00
|
|
|
fi
|
2018-12-02 05:06:37 +00:00
|
|
|
}
|
2016-01-08 21:47:41 +00:00
|
|
|
|
2018-12-02 05:06:37 +00:00
|
|
|
: ${ATF_TEST=false}
|
|
|
|
if ! $ATF_TEST; then
|
|
|
|
geom_tap_test_setup
|
2016-01-08 21:47:41 +00:00
|
|
|
fi
|