~youscribe/parted/3.1

« back to all changes in this revision

Viewing changes to tests/t6100-mdraid-partitions.sh

  • Committer: Guilhem Lettron
  • Date: 2012-10-22 14:37:59 UTC
  • Revision ID: guilhem+ubuntu@lettron.fr-20121022143759-m403kecgz13sknvp
3.1 from tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# verify that new kernel is informed about partitions on mdraid devices
 
3
 
 
4
# Copyright (C) 2011-2012 Free Software Foundation, Inc.
 
5
 
 
6
# This program is free software; you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation; either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
 
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
 
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
. "${srcdir=.}/init.sh"; path_prepend_ ../parted
 
20
 
 
21
require_root_
 
22
require_scsi_debug_module_
 
23
require_mdadm_
 
24
 
 
25
# create memory-backed device
 
26
scsi_debug_setup_ dev_size_mb=10 > dev-name ||
 
27
  skip_ 'failed to create scsi_debug device'
 
28
scsi_dev=$(cat dev-name)
 
29
 
 
30
# Arbitrary number, not likely to be used already
 
31
md_name=md99
 
32
md_dev=/dev/$md_name
 
33
 
 
34
test -b $md_dev && skip_ "$md_dev already exists"
 
35
 
 
36
# Use gpt and create two partitions on the device.
 
37
parted -s "$scsi_dev" mklabel gpt \
 
38
    mkpart p1 ext2 1M 4M \
 
39
    mkpart p2 ext2 5M 8M > out 2>&1 || fail=1
 
40
compare /dev/null out || fail=1
 
41
 
 
42
cleanup_fn_() {
 
43
  # stop mdraid array
 
44
  mdadm -S $md_dev || warn_ "Failed to stop MD array, $md_dev"
 
45
}
 
46
 
 
47
# create mdraid on top of both partitions
 
48
mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2"
 
49
 
 
50
# create gpt and two partitions on the raid device
 
51
parted -s $md_dev mklabel gpt \
 
52
    mkpart r1 ext2 1M 2M \
 
53
    mkpart r2 ext2 2M 3M > out 2>&1 || fail=1
 
54
compare /dev/null out || fail=1
 
55
 
 
56
# Verify that kernel has been informed about the second device.
 
57
grep "${md_name}p2" /proc/partitions || { fail=1; cat /proc/partitions; }
 
58
 
 
59
# Remove partitions from the raid device.
 
60
parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1
 
61
compare /dev/null out || fail=1
 
62
 
 
63
# Verify that kernel has been informed about those removals.
 
64
grep "${md_name}p[12]" /proc/partitions && { fail=1; cat /proc/partitions; }
 
65
 
 
66
Exit $fail