1 From 822439e4eaa4bb758d9058022154973cd690eca7 Mon Sep 17 00:00:00 2001
2 From: "Brian C. Lane" <bcl@redhat.com>
3 Date: Fri, 5 Jun 2015 13:46:29 -0700
4 Subject: [PATCH] tests: Make sure the extended partition length is correct
7 parted tells the kernel the wrong length when reporting a resize of an
8 extended partition. Make sure the length is 2 for 512b sectors and 1
11 (cherry picked from commit 31b5bfa4cd0b2e2944af22466e7b7d88ad94c4c9)
13 tests/Makefile.am | 1 +
14 tests/t2320-dos-extended-noclobber.sh | 48 +++++++++++++++++++++++++++++++++++
15 2 files changed, 49 insertions(+)
16 create mode 100644 tests/t2320-dos-extended-noclobber.sh
18 diff --git a/tests/Makefile.am b/tests/Makefile.am
19 index ce8391d..001b9de 100644
20 --- a/tests/Makefile.am
21 +++ b/tests/Makefile.am
22 @@ -47,6 +47,7 @@ TESTS = \
23 t2201-pc98-label-recog.sh \
24 t2300-dos-label-extended-bootcode.sh \
25 t2310-dos-extended-2-sector-min-offset.sh \
26 + t2320-dos-extended-noclobber.sh \
27 t2400-dos-hfs-partition-type.sh \
28 t2500-probe-corrupt-hfs.sh \
30 diff --git a/tests/t2320-dos-extended-noclobber.sh b/tests/t2320-dos-extended-noclobber.sh
32 index 0000000..6f3dfff
34 +++ b/tests/t2320-dos-extended-noclobber.sh
37 +# Ensure that the extended partition reports the correct length
38 +# after adding another partition.
40 +# Copyright (C) 2015 Free Software Foundation, Inc.
42 +# This program is free software; you can redistribute it and/or modify
43 +# it under the terms of the GNU General Public License as published by
44 +# the Free Software Foundation; either version 3 of the License, or
45 +# (at your option) any later version.
47 +# This program is distributed in the hope that it will be useful,
48 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
49 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 +# GNU General Public License for more details.
52 +# You should have received a copy of the GNU General Public License
53 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
55 +. "${srcdir=.}/init.sh"; path_prepend_ ../parted
58 +require_scsi_debug_module_
60 +# create memory-backed device
62 +scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name ||
63 + skip_ 'failed to create scsi_debug device'
64 +scsi_dev=$(cat dev-name)
66 +# Create a DOS label with an extended partition and a primary partition
67 +parted -s $scsi_dev mklabel msdos || fail=1
68 +parted -s $scsi_dev mkpart extended 1 5 > out 2>&1 || fail=1
69 +parted -s $scsi_dev mkpart primary 5 10 > out 2>&1 || fail=1
71 +# Make sure the size of the extended partition is correct.
72 +# 2 sectors for 512b and 1 sector for larger. /sys/.../size is in
73 +# 512b blocks so convert accordingly.
74 +dev=${scsi_dev#/dev/}
75 +ext_len=$(cat /sys/block/$dev/${dev}1/size)
76 +if [ $ss -eq 512 ]; then
79 + expected_len=$((ss / 512))
81 +[ $ext_len -eq $expected_len ] || fail=1