xref: /freebsd/tests/sys/geom/class/mirror/2_test.sh (revision 55141f2c8991b2a6adbf30bb0fe3e6cbc303f06d)
1#!/bin/sh
2
3. `dirname $0`/conf.sh
4
5echo "1..4"
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
31dd if=/dev/${us0} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
32if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
33	echo "not ok 2"
34else
35	echo "ok 2"
36fi
37dd if=/dev/${us1} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
38if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
39	echo "not ok 3"
40else
41	echo "ok 3"
42fi
43
44dd if=/dev/${us2} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
45if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
46	echo "not ok 4"
47else
48	echo "ok 4"
49fi
50
51rm -f ${src} ${dst}
52