xref: /freebsd/tests/sys/geom/class/mirror/3_test.sh (revision edf8578117e8844e02c0121147f45e4609b30680)
1#!/bin/sh
2
3. `dirname $0`/conf.sh
4
5echo "1..5"
6
7balance="round-robin"
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
16us0=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
17us1=$(attach_md -t malloc -s `expr $nblocks1 + 1`) || exit 1
18us2=$(attach_md -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
56# mirror/${name} should be removed.
57if [ -c /dev/${name} ]; then
58	echo "not ok 5"
59else
60	echo "ok 5"
61fi
62
63rm -f ${src} ${dst}
64