]> git.pld-linux.org Git - packages/parted.git/blob - 0009-tests-Add-a-test-for-device-mapper-partition-sizes.patch
- rel 4; tons of patches from FC
[packages/parted.git] / 0009-tests-Add-a-test-for-device-mapper-partition-sizes.patch
1 From 8ab27474806687a2af7efb008b80b33615e6eb1d Mon Sep 17 00:00:00 2001
2 From: "Brian C. Lane" <bcl@redhat.com>
3 Date: Wed, 4 Feb 2015 16:31:00 -0800
4 Subject: [PATCH 09/11] tests: Add a test for device-mapper partition sizes
5
6 device-mapper uses 512b sector units, not device specific sector sizes.
7 This test ensures that the correct partition size is created, no matter
8 what the device's sector size is.
9 ---
10  tests/Makefile.am              |  1 +
11  tests/t6006-dm-512b-sectors.sh | 68 ++++++++++++++++++++++++++++++++++++++++++
12  2 files changed, 69 insertions(+)
13  create mode 100644 tests/t6006-dm-512b-sectors.sh
14
15 diff --git a/tests/Makefile.am b/tests/Makefile.am
16 index b726366..ce8391d 100644
17 --- a/tests/Makefile.am
18 +++ b/tests/Makefile.am
19 @@ -69,6 +69,7 @@ TESTS = \
20    t6003-dm-hide.sh \
21    t6004-dm-many-partitions.sh \
22    t6005-dm-uuid.sh \
23 +  t6006-dm-512b-sectors.sh \
24    t6100-mdraid-partitions.sh \
25    t7000-scripting.sh \
26    t8000-loop.sh \
27 diff --git a/tests/t6006-dm-512b-sectors.sh b/tests/t6006-dm-512b-sectors.sh
28 new file mode 100644
29 index 0000000..31abba9
30 --- /dev/null
31 +++ b/tests/t6006-dm-512b-sectors.sh
32 @@ -0,0 +1,68 @@
33 +#!/bin/sh
34 +# device-mapper sector sizes are 512b, make sure partitions are the correct
35 +# size when using larger sector sizes and a linear dm table.
36 +
37 +# Copyright (C) 2015 Free Software Foundation, Inc.
38 +
39 +# This program is free software; you can redistribute it and/or modify
40 +# it under the terms of the GNU General Public License as published by
41 +# the Free Software Foundation; either version 3 of the License, or
42 +# (at your option) any later version.
43 +
44 +# This program is distributed in the hope that it will be useful,
45 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
46 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47 +# GNU General Public License for more details.
48 +
49 +# You should have received a copy of the GNU General Public License
50 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
51 +
52 +. "${srcdir=.}/init.sh"; path_prepend_ ../parted
53 +
54 +require_root_
55 +require_scsi_debug_module_
56 +
57 +grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
58 +  skip_ 'this system lacks a new-enough libblkid'
59 +
60 +(dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
61 +
62 +# Device maps names - should be random to not conflict with existing ones on
63 +# the system
64 +linear_=plinear-$$test
65 +
66 +cleanup_fn_() {
67 +    i=0
68 +    udevadm settle
69 +    while [ $i -lt 10 ] ; do
70 +      [ -e "/dev/mapper/${linear_}1" ] && dmsetup remove ${linear_}1
71 +      sleep .2
72 +      [ -e "/dev/mapper/$linear_" ] && dmsetup remove $linear_
73 +      sleep .2
74 +      [ -e "/dev/mapper/${linear_}1" -o -e "/dev/mapper/$linear_" ] || i=10
75 +      i=$((i + 1))
76 +    done
77 +    udevadm settle
78 +}
79 +
80 +# Create a 500M device
81 +ss=$sector_size_
82 +scsi_debug_setup_ sector_size=$ss dev_size_mb=500 > dev-name ||
83 +  skip_ 'failed to create scsi_debug device'
84 +scsi_dev=$(cat dev-name)
85 +
86 +# Size of device, in 512b units
87 +scsi_dev_size=$(blockdev --getsz $scsi_dev) || framework_failure
88 +
89 +dmsetup create $linear_ --table "0 $scsi_dev_size linear $scsi_dev 0" || framework_failure
90 +dev="/dev/mapper/$linear_"
91 +
92 +# Create msdos partition table with a partition from 1MiB to 100MiB
93 +parted -s $dev mklabel msdos mkpart primary ext2 1MiB 101MiB > out 2>&1 || fail=1
94 +compare /dev/null out || fail=1
95 +
96 +# The size of the partition should be 100MiB, or 204800 512b sectors
97 +p1_size=$(blockdev --getsz ${dev}1) || framework_failure
98 +[ $p1_size == 204800 ] || fail=1
99 +
100 +Exit $fail
101 -- 
102 2.1.0
103
This page took 0.102467 seconds and 3 git commands to generate.