5_test.sh revision 153186
1#!/bin/sh
2# $FreeBSD: head/tools/regression/geom_mirror/test-5.t 153186 2005-12-07 01:27:23Z pjd $
3
4. `dirname $0`/conf.sh
5
6echo "1..5"
7
8balance="split"
9us0=45
10us1=`expr $us0 + 1`
11us2=`expr $us0 + 2`
12ddbs=8192
13nblocks1=1024
14nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
15src=`mktemp /tmp/$base.XXXXXX` || exit 1
16dst=`mktemp /tmp/$base.XXXXXX` || exit 1
17
18dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
19
20mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
21mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
22mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
23
24gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
25devwait
26
27dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
28
29dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
30if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
31	echo "not ok 1"
32else
33	echo "ok 1"
34fi
35
36gmirror remove $name md${us0}
37dd if=/dev/mirror/${name} 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
44gmirror remove $name md${us1}
45dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
46if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
47	echo "not ok 3"
48else
49	echo "ok 3"
50fi
51
52gmirror remove $name md${us2}
53dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
54if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
55	echo "not ok 4"
56else
57	echo "ok 4"
58fi
59
60# mirror/${name} should be removed.
61if [ -c /dev/${name} ]; then
62	echo "not ok 5"
63else
64	echo "ok 5"
65fi
66
67mdconfig -d -u $us0
68mdconfig -d -u $us1
69mdconfig -d -u $us2
70rm -f ${src} ${dst}
71