tests/t6100-mdraid-partitions.sh: New file. tests/Makefile.am: Run this test. --- tests/Makefile.am | 1 + tests/t6100-mdraid-partitions.sh | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 0 deletions(-) create mode 100755 tests/t6100-mdraid-partitions.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am index 5bc513d..616684e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -49,6 +49,7 @@ TESTS = \ t4300-nilfs2-tiny.sh \ t5000-tags.sh \ t6000-dm.sh \ + t6100-mdraid-partitions.sh \ t7000-scripting.sh \ t8000-loop.sh \ t8001-loop-blkpg.sh \ diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh new file mode 100755 index 0000000..a3a2d0b --- /dev/null +++ b/tests/t6100-mdraid-partitions.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# verify that new kernel is informed about partitions on mdraid devices + +# Copyright (C) 2011 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +. "${srcdir=.}/init.sh"; path_prepend_ ../parted + +require_root_ +require_scsi_debug_module_ +require_mdadm_ + +# create memory-backed device +scsi_debug_setup_ dev_size_mb=10 > dev-name || + skip_ 'failed to create scsi_debug device' +scsi_dev=$(cat dev-name) + +# Arbitrary number, not likely to be used already +md_name="md99" + +test -b /dev/${md_name} && skip_ "/dev/${md_name} already exists" + +# create gpt and two partitions on the device +parted -s "$scsi_dev" mklabel gpt mkpart p1 ext2 1M 4M mkpart p2 ext2 5M 8M > out 2>&1 || fail=1 +compare out /dev/null || fail=1 + +# create mdraid on top of both partitions +mdadm -C /dev/${md_name} --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2" + +# create gpt and two partitions on the raid device +parted -s /dev/${md_name} mklabel gpt mkpart r1 ext2 1M 2M mkpart r2 ext2 2M 3M > out 2>&1 || fail=1 +compare out /dev/null || fail=1 + +# verify that kernel has been informed about the second device +grep -s "${md_name}p2" /proc/partitions || { fail=1; cat /proc/partitions; } + +# remove partitions from the raid device +parted -s /dev/${md_name} rm 2 rm 1 > out 2>&1 || fail=1 +compare out /dev/null || fail=1 + +# verify that kernel has been informed about removing thos partitions +grep -s "${md_name}p[12]" /proc/partitions && { fail=1; cat /proc/partitions; } + +# stop mdraid array +mdadm -S /dev/${md_name} || { echo "Failed to stop MD array"; fail=1; } + +Exit $fail -- 1.7.7

