Blame SOURCES/0012-tests-Make-sure-the-extended-partition-length-is-cor.patch

003ee8
From 822439e4eaa4bb758d9058022154973cd690eca7 Mon Sep 17 00:00:00 2001
003ee8
From: "Brian C. Lane" <bcl@redhat.com>
003ee8
Date: Fri, 5 Jun 2015 13:46:29 -0700
003ee8
Subject: [PATCH] tests: Make sure the extended partition length is correct
003ee8
 (#1135493)
003ee8
003ee8
parted tells the kernel the wrong length when reporting a resize of an
003ee8
extended partition. Make sure the length is 2 for 512b sectors and 1
003ee8
sector for larger.
003ee8
003ee8
(cherry picked from commit 31b5bfa4cd0b2e2944af22466e7b7d88ad94c4c9)
003ee8
---
003ee8
 tests/Makefile.am                     |  1 +
003ee8
 tests/t2320-dos-extended-noclobber.sh | 48 +++++++++++++++++++++++++++++++++++
003ee8
 2 files changed, 49 insertions(+)
003ee8
 create mode 100644 tests/t2320-dos-extended-noclobber.sh
003ee8
003ee8
diff --git a/tests/Makefile.am b/tests/Makefile.am
003ee8
index ce8391d..001b9de 100644
003ee8
--- a/tests/Makefile.am
003ee8
+++ b/tests/Makefile.am
003ee8
@@ -47,6 +47,7 @@ TESTS = \
003ee8
   t2201-pc98-label-recog.sh \
003ee8
   t2300-dos-label-extended-bootcode.sh \
003ee8
   t2310-dos-extended-2-sector-min-offset.sh \
003ee8
+  t2320-dos-extended-noclobber.sh \
003ee8
   t2400-dos-hfs-partition-type.sh \
003ee8
   t2500-probe-corrupt-hfs.sh \
003ee8
   t3000-resize-fs.sh \
003ee8
diff --git a/tests/t2320-dos-extended-noclobber.sh b/tests/t2320-dos-extended-noclobber.sh
003ee8
new file mode 100644
003ee8
index 0000000..6f3dfff
003ee8
--- /dev/null
003ee8
+++ b/tests/t2320-dos-extended-noclobber.sh
003ee8
@@ -0,0 +1,48 @@
003ee8
+#!/bin/sh
003ee8
+# Ensure that the extended partition reports the correct length
003ee8
+# after adding another partition.
003ee8
+
003ee8
+# Copyright (C) 2015 Free Software Foundation, Inc.
003ee8
+
003ee8
+# This program is free software; you can redistribute it and/or modify
003ee8
+# it under the terms of the GNU General Public License as published by
003ee8
+# the Free Software Foundation; either version 3 of the License, or
003ee8
+# (at your option) any later version.
003ee8
+
003ee8
+# This program is distributed in the hope that it will be useful,
003ee8
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
003ee8
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
003ee8
+# GNU General Public License for more details.
003ee8
+
003ee8
+# You should have received a copy of the GNU General Public License
003ee8
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
003ee8
+
003ee8
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
003ee8
+
003ee8
+require_root_
003ee8
+require_scsi_debug_module_
003ee8
+
003ee8
+# create memory-backed device
003ee8
+ss=$sector_size_
003ee8
+scsi_debug_setup_ sector_size=$ss dev_size_mb=10 > dev-name ||
003ee8
+  skip_ 'failed to create scsi_debug device'
003ee8
+scsi_dev=$(cat dev-name)
003ee8
+
003ee8
+# Create a DOS label with an extended partition and a primary partition
003ee8
+parted -s $scsi_dev mklabel msdos || fail=1
003ee8
+parted -s $scsi_dev mkpart extended 1 5 > out 2>&1 || fail=1
003ee8
+parted -s $scsi_dev mkpart primary 5 10 > out 2>&1 || fail=1
003ee8
+
003ee8
+# Make sure the size of the extended partition is correct.
003ee8
+# 2 sectors for 512b and 1 sector for larger. /sys/.../size is in
003ee8
+# 512b blocks so convert accordingly.
003ee8
+dev=${scsi_dev#/dev/}
003ee8
+ext_len=$(cat /sys/block/$dev/${dev}1/size)
003ee8
+if [ $ss -eq 512 ]; then
003ee8
+    expected_len=2
003ee8
+else
003ee8
+    expected_len=$((ss / 512))
003ee8
+fi
003ee8
+[ $ext_len -eq $expected_len ] || fail=1
003ee8
+
003ee8
+Exit $fail
003ee8
-- 
003ee8
2.4.3
003ee8