xref: /freebsd/tests/sys/geom/class/raid3/7_test.sh (revision 09a53ad8f1318c5daae6cfb19d97f4f6459f0013)
1#!/bin/sh
2# $FreeBSD$
3
4. `dirname $0`/conf.sh
5
6echo "1..1"
7
8ddbs=2048
9nblocks1=1024
10nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
11src=`mktemp $base.XXXXXX` || exit 1
12dst=`mktemp $base.XXXXXX` || exit 1
13
14us0=$(attach_md -t malloc -s $(expr $nblocks1 + 1)) || exit 1
15us1=$(attach_md -t malloc -s $(expr $nblocks1 + 1)) || exit 1
16us2=$(attach_md -t malloc -s $(expr $nblocks1 + 1)) || exit 1
17
18dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
19
20graid3 label $name /dev/${us0} /dev/${us1} /dev/${us2} || exit 1
21devwait
22
23dd if=${src} of=/dev/raid3/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
24
25#
26# Rebuild of PARITY component.
27#
28graid3 remove -n 2 $name
29dd if=/dev/zero of=/dev/${us2} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1
30graid3 insert -n 2 $name md${us2}
31sleep 1
32# Remove DATA component, so PARITY component can be used while reading.
33graid3 remove -n 1 $name
34dd if=/dev/zero of=/dev/${us1} bs=512 count=`expr $nblocks1 + 1` >/dev/null 2>&1
35
36dd if=/dev/raid3/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
37if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
38	echo "not ok 1"
39else
40	echo "ok 1"
41fi
42
43rm -f ${src} ${dst}
44