1#!/bin/sh 2 3TEST_MDS_FILE="${TMPDIR}/test_mds.$(basename $0)" 4 5devwait() 6{ 7 while :; do 8 if [ -c /dev/${class}/${name} ]; then 9 return 10 fi 11 sleep 0.2 12 done 13} 14 15attach_md() 16{ 17 local test_md 18 19 [ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices" 20 test_md=$(mdconfig -a "$@") || exit 21 echo $test_md >> $TEST_MDS_FILE || exit 22 echo $test_md 23} 24 25detach_md() 26{ 27 local test_md unit 28 29 test_md=$1 30 unit=${test_md#md} 31 mdconfig -d -u $unit || exit 32 sed -i '' "/^${test_md}$/d" $TEST_MDS_FILE || exit 33} 34 35geom_test_cleanup() 36{ 37 local test_md 38 39 if [ -f "$TEST_MDS_FILE" ]; then 40 while read test_md; do 41 # The "#" tells the TAP parser this is a comment 42 echo "# Removing test memory disk: $test_md" 43 mdconfig -d -u $test_md 44 done < $TEST_MDS_FILE 45 rm -f "$TEST_MDS_FILE" 46 fi 47} 48 49geom_load_class_if_needed() 50{ 51 local class=$1 52 53 # If the geom class isn't already loaded, try loading it. 54 if ! kldstat -q -m g_${class}; then 55 if ! geom ${class} load; then 56 echo "could not load module for geom class=${class}" 57 return 1 58 fi 59 fi 60 return 0 61} 62 63geom_atf_test_setup() 64{ 65 if ! error_message=$(geom_load_class_if_needed $class); then 66 atf_skip "$error_message" 67 fi 68} 69 70geom_tap_test_setup() 71{ 72 if ! error_message=$(geom_load_class_if_needed $class); then 73 echo "1..0 # SKIP $error_message" 74 exit 0 75 fi 76} 77 78: ${ATF_TEST=false} 79if ! $ATF_TEST; then 80 geom_tap_test_setup 81fi 82