]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/geom_mirror/test-6.t
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / regression / geom_mirror / test-6.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 . `dirname $0`/conf.sh
5
6 echo "1..2"
7
8 balance="split"
9 us0=45
10 us1=`expr $us0 + 1`
11 us2=`expr $us0 + 2`
12 ddbs=8192
13 nblocks1=1024
14 nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
15 src=`mktemp /tmp/$base.XXXXXX` || exit 1
16 dst=`mktemp /tmp/$base.XXXXXX` || exit 1
17
18 dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
19
20 mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
21 mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
22 mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
23
24 gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/md${us0} /dev/md${us1} || exit 1
25 devwait
26
27 dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
28 dd if=/dev/zero of=/dev/md${us2} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
29
30 dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
31 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
32         echo "not ok 1"
33 else
34         echo "ok 1"
35 fi
36
37 # Connect disk to the mirror.
38 gmirror insert ${name} md${us2}
39 # Wait for synchronization.
40 sleep 1
41 dd if=/dev/md${us2} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
42 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
43         echo "not ok 2"
44 else
45         echo "ok 2"
46 fi
47
48 gmirror remove $name md${us0} md${us1} md${us2}
49 mdconfig -d -u $us0
50 mdconfig -d -u $us1
51 mdconfig -d -u $us2
52 rm -f ${src} ${dst}