linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: mwilck@arcor.de
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH] tests/env-ddf-template: helper for new unit test
Date: Wed, 31 Jul 2013 16:49:27 +1000	[thread overview]
Message-ID: <20130731164927.0b1a4181@notabene.brown> (raw)
In-Reply-To: <1375248992-7130-1-git-send-email-mwilck@arcor.de>

[-- Attachment #1: Type: text/plain, Size: 3382 bytes --]

On Wed, 31 Jul 2013 07:36:32 +0200 mwilck@arcor.de wrote:

> From: Martin Wilck <mwilck@arcor.de>
> 
> I forgot to check in this helper script, similar to the one for IMSM.
> It is needed by tests/10ddf-create-fail-rebuild.
> 
> Signed-off-by: Martin Wilck <mwilck@arcor.de>
> ---
>  tests/env-ddf-template |   76 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 76 insertions(+), 0 deletions(-)
>  create mode 100644 tests/env-ddf-template
> 
> diff --git a/tests/env-ddf-template b/tests/env-ddf-template
> new file mode 100644
> index 0000000..28e19d0
> --- /dev/null
> +++ b/tests/env-ddf-template
> @@ -0,0 +1,76 @@
> +ddf_check() {
> +    udevadm settle
> +    case $1 in
> +    container )
> +        grep -s "blocks super external:ddf" /proc/mdstat > /dev/null || {
> +            echo >&2 "**Fatal** Correctly formed container not found"; cat /proc/mdstat; exit 1; }
> +        ;;
> +    member )
> +        t_member=$2
> +        t_num_disks=$3
> +        t_level=$4
> +        t_rd_size=$5
> +        t_size=$6
> +        t_offset=$7
> +        t_chunk=$8
> +	t_layout=$9
> +	
> +	if [ $t_chunk -ne 0 ]; then
> +	    t_rd_size=$((t_rd_size & ~(t_chunk - 1)))
> +        fi
> +	case $t_level in
> +	0) t_size=$((t_num_disks*$t_rd_size));;
> +	1) t_size=$t_rd_size;;
> +	4|5) t_size=$(((t_num_disks-1)*$t_rd_size));;
> +	6) t_size=$(((t_num_disks-2)*$t_rd_size));;
> +	10) t_size=$((t_num_disks*$t_rd_size/t_layout));;
> +	esac
> +
> +        err=0
> +
> +        eval `stat -L -c "let major=0x%t; let minor=0x%T;" $t_member`
> +        sysfs=/sys/dev/block/${major}:${minor}
> +        if [ ! -f ${sysfs}/md/array_state ]; then
> +            echo "**Fatal**: Array member $t_member not found" >&2; cat /proc/mdstat >&2; exit 1
> +        fi
> +        _chunk=`cat ${sysfs}/md/chunk_size`
> +        if [ $t_chunk -ne $((_chunk/1024)) ]; then
> +            echo "**Error**: Chunk size mismatch - expected $t_chunk, actual $_chunk" >&2
> +            err=$((err + 1))
> +        fi
> +        for i in `seq 0 $((t_num_disks - 1))`; do
> +	    _offset=`cat ${sysfs}/md/rd${i}/offset`
> +	    if [ $t_offset -ne $((_offset / 2)) ]; then
> +		echo "**Error**: Offset mismatch - expected $t_offset, actual $((_offset/2))" >&2
> +		err=$((err + 1))
> +	    fi
> +	    _rd_size=`cat ${sysfs}/md/rd${i}/size`
> +	    if [ $t_rd_size -ne $_rd_size ]; then
> +		echo "**Error**: Component size mismatch - expected $t_rd_size, actual $_rd_size" >&2
> +		err=$((err + 1))
> +	    fi
> +        done
> +        _size=`cat ${sysfs}/md/array_size`
> +	[ o$_size = odefault ] && _size=$(($(cat ${sysfs}/size)/2))
> +        if [ $t_size -ne $_size ]; then
> +            echo "**Error**: Array size mismatch - expected $t_size, actual $_size" >&2
> +            err=$((err + 1))
> +        fi
> +        if [ $err -gt 0 ]; then
> +            echo "$t_member failed check" >&2
> +            cat /proc/mdstat >&2
> +            mdadm -E /dev/loop8 >&2
> +            exit 1
> +        fi
> +        ;;
> +    * )
> +        echo >&2 "**Error** unknown check $1"; exit 1;
> +    esac
> +}
> +
> +container=/dev/md/ddf
> +member0=/dev/md/vol0
> +member1=/dev/md/vol1
> +member2=/dev/md/vol2
> +member3=/dev/md/vol3
> +member4=/dev/md/vol4


applied, thanks.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

      reply	other threads:[~2013-07-31  6:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 20:58 Suspicious test failure - mdmon misses recovery events on loop devices Martin Wilck
2013-07-29  6:55 ` NeilBrown
2013-07-29 20:39   ` Martin Wilck
2013-07-29 20:42     ` Martin Wilck
2013-07-30  0:42       ` NeilBrown
2013-07-30 21:16         ` Martin Wilck
2013-07-30 21:18           ` [PATCH 00/10] Two bug fixes and a lot of debug code mwilck
2013-07-31  3:10             ` NeilBrown
2013-07-30 21:18           ` [PATCH 01/10] DDF: ddf_activate_spare: bugfix for 62ff3c40 mwilck
2013-07-30 21:18           ` [PATCH 02/10] DDF: log disk status changes more nicely mwilck
2013-07-30 21:18           ` [PATCH 03/10] DDF: ddf_process_update: log offsets for conf changes mwilck
2013-07-30 21:18           ` [PATCH 04/10] DDF: load_ddf_header: more error logging mwilck
2013-07-30 21:18           ` [PATCH 05/10] DDF: ddf_set_disk: add some debug messages mwilck
2013-07-30 21:18           ` [PATCH 06/10] monitor: read_and_act: log status when called mwilck
2013-07-31  2:59             ` NeilBrown
2013-07-31  5:28               ` Martin Wilck
2013-07-30 21:18           ` [PATCH 07/10] mdmon: wait_and_act: fix debug message for SIGUSR1 mwilck
2013-07-30 21:18           ` [PATCH 08/10] mdmon: manage_member: debug messages for array state mwilck
2013-07-30 21:18           ` [PATCH 09/10] mdmon: manage_member: fix race condition during slow meta data writes mwilck
2013-07-30 21:18           ` [PATCH 10/10] tests/10ddf-create-fail-rebuild: new unit test for DDF mwilck
2013-07-31  5:36             ` [PATCH] tests/env-ddf-template: helper for new unit test mwilck
2013-07-31  6:49               ` NeilBrown [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130731164927.0b1a4181@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-raid@vger.kernel.org \
    --cc=mwilck@arcor.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).