1153187Spjd#!/bin/sh
2153187Spjd# $FreeBSD: releng/10.2/tools/regression/geom_raid3/test-6.t 153187 2005-12-07 01:28:59Z pjd $
3153187Spjd
4153187Spjd. `dirname $0`/conf.sh
5153187Spjd
6153187Spjdecho "1..1"
7153187Spjd
8153187Spjdus0=45
9153187Spjdus1=`expr $us0 + 1`
10153187Spjdus2=`expr $us0 + 2`
11153187Spjdddbs=2048
12153187Spjdnblocks1=1024
13153187Spjdnblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
14153187Spjdsrc=`mktemp /tmp/$base.XXXXXX` || exit 1
15153187Spjddst=`mktemp /tmp/$base.XXXXXX` || exit 1
16153187Spjd
17153187Spjddd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
18153187Spjd
19153187Spjdmdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
20153187Spjdmdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
21153187Spjdmdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
22153187Spjd
23153187Spjdgraid3 label $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
24153187Spjddevwait
25153187Spjd
26153187Spjddd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
27153187Spjd
28153187Spjd#
29153187Spjd# Rebuild of DATA component.
30153187Spjd#
31153187Spjdgraid3 remove -n 1 $name
32153187Spjddd if=/dev/zero of=/dev/md${us1} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1
33153187Spjdgraid3 insert -n 1 $name md${us1}
34153187Spjdsleep 1
35153187Spjd
36153187Spjddd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
37153187Spjdif [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
38153187Spjd	echo "not ok 1"
39153187Spjdelse
40153187Spjd	echo "ok 1"
41153187Spjdfi
42153187Spjd
43153187Spjdgraid3 stop $name
44153187Spjdmdconfig -d -u $us0
45153187Spjdmdconfig -d -u $us1
46153187Spjdmdconfig -d -u $us2
47153187Spjdrm -f ${src} ${dst}
48