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