xref: /freebsd/tests/sys/geom/class/mirror/conf.sh (revision e8643b01e6312a56d1e44a760fb4e95f0b10b54c)
1#!/bin/sh
2# $FreeBSD$
3
4name="$(mktemp -u mirror.XXXXXX)"
5class="mirror"
6base=`basename $0`
7
8gmirror_test_cleanup()
9{
10	[ -c /dev/$class/$name ] && gmirror destroy $name
11	geom_test_cleanup
12}
13trap gmirror_test_cleanup ABRT EXIT INT TERM
14
15syncwait()
16{
17	while $(gmirror status -s $name | grep -q SYNCHRONIZING); do
18		sleep 0.1;
19	done
20}
21
22consumerrefs()
23{
24	gclass=$1
25	geom=$2
26
27	if [ $# -ne 2 ]; then
28		echo "Bad usage consumerrefs" >&2
29		exit 1
30	fi
31
32	geom "${gclass}" list "${geom}" | \
33	    grep -A5 ^Consumers | \
34	    grep Mode | \
35	    cut -d: -f2
36}
37
38disconnectwait()
39{
40	gclass=$1
41	geom=$2
42
43	if [ $# -ne 2 ]; then
44		echo "Bad usage disconnectwait" >&2
45		exit 1
46	fi
47
48	while [ $(consumerrefs "$gclass" "$geom") != r0w0e0 ]; do
49		sleep 0.05
50	done
51}
52
53. `dirname $0`/../geom_subr.sh
54