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