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