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