xref: /freebsd/tests/sys/geom/class/mirror/5_test.sh (revision a0409676120c1e558d0ade943019934e0f15118d)
1#!/bin/sh
2# $FreeBSD$
3
4. `dirname $0`/conf.sh
5
6echo "1..5"
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} /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
32
33gmirror remove $name ${us0}
34dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
35if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
36	echo "not ok 2"
37else
38	echo "ok 2"
39fi
40
41gmirror remove $name ${us1}
42dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
43if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
44	echo "not ok 3"
45else
46	echo "ok 3"
47fi
48
49gmirror remove $name ${us2}
50dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
51if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
52	echo "not ok 4"
53else
54	echo "ok 4"
55fi
56
57# mirror/${name} should be removed.
58if [ -c /dev/${name} ]; then
59	echo "not ok 5"
60else
61	echo "ok 5"
62fi
63
64rm -f ${src} ${dst}
65