xref: /freebsd/tests/sys/geom/class/mirror/4_test.sh (revision 49b49cda41feabe3439f7318e8bf40e3896c7bf4)
1#!/bin/sh
2# $FreeBSD$
3
4. `dirname $0`/conf.sh
5
6echo "1..5"
7
8balance="load"
9ddbs=2048
10nblocks1=1024
11nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
12src=`mktemp $base.XXXXXX` || exit 1
13dst=`mktemp $base.XXXXXX` || exit 1
14
15dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
16
17us0=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
18us1=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
19us2=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
20
21gmirror label -b $balance $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
22devwait
23
24dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
25
26dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
27if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
28	echo "not ok 1"
29else
30	echo "ok 1"
31fi
32
33gmirror remove $name ${us0}
34dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
35if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
36	echo "not ok 2"
37else
38	echo "ok 2"
39fi
40
41gmirror remove $name ${us1}
42dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
43if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
44	echo "not ok 3"
45else
46	echo "ok 3"
47fi
48
49gmirror remove $name ${us2}
50dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
51if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
52	echo "not ok 4"
53else
54	echo "ok 4"
55fi
56
57gmirror destroy $name
58
59# mirror/${name} should be removed.
60if [ -c /dev/${name} ]; then
61	echo "not ok 5"
62else
63	echo "ok 5"
64fi
65
66rm -f ${src} ${dst}
67