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