]>
Commit | Line | Data |
---|---|---|
c886eb9d AM |
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 | |
5 | (#1135493) | |
6 | ||
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 | |
9 | sector for larger. | |
10 | ||
11 | (cherry picked from commit 31b5bfa4cd0b2e2944af22466e7b7d88ad94c4c9) | |
12 | --- | |
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 | |
17 | ||
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 \ | |
29 | t3000-resize-fs.sh \ | |
30 | diff --git a/tests/t2320-dos-extended-noclobber.sh b/tests/t2320-dos-extended-noclobber.sh | |
31 | new file mode 100644 | |
32 | index 0000000..6f3dfff | |
33 | --- /dev/null | |
34 | +++ b/tests/t2320-dos-extended-noclobber.sh | |
35 | @@ -0,0 +1,48 @@ | |
36 | +#!/bin/sh | |
37 | +# Ensure that the extended partition reports the correct length | |
38 | +# after adding another partition. | |
39 | + | |
40 | +# Copyright (C) 2015 Free Software Foundation, Inc. | |
41 | + | |
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. | |
46 | + | |
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. | |
51 | + | |
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/>. | |
54 | + | |
55 | +. "${srcdir=.}/init.sh"; path_prepend_ ../parted | |
56 | + | |
57 | +require_root_ | |
58 | +require_scsi_debug_module_ | |
59 | + | |
60 | +# create memory-backed device | |
61 | +ss=$sector_size_ | |
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) | |
65 | + | |
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 | |
70 | + | |
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 | |
77 | + expected_len=2 | |
78 | +else | |
79 | + expected_len=$((ss / 512)) | |
80 | +fi | |
81 | +[ $ext_len -eq $expected_len ] || fail=1 | |
82 | + | |
83 | +Exit $fail | |
84 | -- | |
85 | 2.4.3 | |
86 |