xref: /freebsd/tests/sys/geom/class/mirror/6_test.sh (revision 95eb4b873b6a8b527c5bd78d7191975dfca38998)
1#!/bin/sh
2
3. `dirname $0`/conf.sh
4
5echo "1..2"
6
7balance="split"
8ddbs=8192
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 -s `expr $ddbs / 2` $name /dev/${us0} /dev/${us1} || exit 1
21devwait
22
23dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
24dd if=/dev/zero of=/dev/${us2} 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
33# Connect disk to the mirror.
34gmirror insert ${name} ${us2}
35# Wait for synchronization.
36sleep 1
37dd if=/dev/${us2} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
38if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
39	echo "not ok 2"
40else
41	echo "ok 2"
42fi
43
44rm -f ${src} ${dst}
45