xref: /freebsd/tests/sys/geom/class/virstor/conf.sh (revision 7affbeeab1c99685012df0d72df2d7a87e09e472)
1#!/bin/sh
2
3class="virstor"
4base=$(atf_get ident)
5TEST_VIRSTOR_DEVS_FILE="${TMPDIR}/test_virstor_devs.$(basename $0)"
6
7gvirstor_dev_setup()
8{
9	# Pick a random name and record it for cleanup.
10	local vdevbase="$(mktemp -u virstor.XXXXXX)" || aft_fail "mktemp"
11	echo "$vdevbase" >> "$TEST_VIRSTOR_DEVS_FILE"
12	eval "${1}='${vdevbase}'"
13}
14
15gvirstor_test_cleanup()
16{
17	local vdevbase
18	if [ -f "$TEST_VIRSTOR_DEVS_FILE" ]; then
19		while read vdevbase; do
20			if [ -c "/dev/$class/$vdevbase" ]; then
21				echo "# Destroying test virstor device:" \
22				    "$vdevbase"
23				gvirstor destroy "$vdevbase"
24			fi
25		done < "$TEST_VIRSTOR_DEVS_FILE"
26	fi
27	geom_test_cleanup
28}
29
30ATF_TEST=true
31. `dirname $0`/../geom_subr.sh
32