73aa139585
- libparted: Fix bug with dupe and empty name
138 lines
4.1 KiB
Diff
138 lines
4.1 KiB
Diff
From 4feec152b1cf9cb2f33ebad86d3e2228a3862033 Mon Sep 17 00:00:00 2001
|
|
From: Phillip Susi <psusi@ubuntu.com>
|
|
Date: Thu, 1 May 2014 22:46:31 -0400
|
|
Subject: [PATCH 113/131] tests: test loop labels
|
|
|
|
Verify previous fixes to loop labels.
|
|
---
|
|
tests/Makefile.am | 1 +
|
|
tests/t1102-loop-label.sh | 104 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
2 files changed, 105 insertions(+)
|
|
create mode 100644 tests/t1102-loop-label.sh
|
|
|
|
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
index e064b8f..26226cf 100644
|
|
--- a/tests/Makefile.am
|
|
+++ b/tests/Makefile.am
|
|
@@ -40,6 +40,7 @@ TESTS = \
|
|
t0501-duplicate.sh \
|
|
t1100-busy-label.sh \
|
|
t1101-busy-partition.sh \
|
|
+ t1102-loop-label.sh \
|
|
t1104-remove-and-add-partition.sh \
|
|
t1700-probe-fs.sh \
|
|
t2200-dos-label-recog.sh \
|
|
diff --git a/tests/t1102-loop-label.sh b/tests/t1102-loop-label.sh
|
|
new file mode 100644
|
|
index 0000000..f5701a3
|
|
--- /dev/null
|
|
+++ b/tests/t1102-loop-label.sh
|
|
@@ -0,0 +1,104 @@
|
|
+#!/bin/sh
|
|
+# make sure that loop labels work correctly
|
|
+# create an actual partition
|
|
+
|
|
+# Copyright (C) 2013 Free Software Foundation, Inc.
|
|
+
|
|
+# This program is free software; you can redistribute it and/or modify
|
|
+# it under the terms of the GNU General Public License as published by
|
|
+# the Free Software Foundation; either version 3 of the License, or
|
|
+# (at your option) any later version.
|
|
+
|
|
+# This program is distributed in the hope that it will be useful,
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
+# GNU General Public License for more details.
|
|
+
|
|
+# You should have received a copy of the GNU General Public License
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
+
|
|
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
|
|
+path_prepend_ ../partprobe
|
|
+require_root_
|
|
+require_scsi_debug_module_
|
|
+ss=$sector_size_
|
|
+
|
|
+scsi_debug_setup_ sector_size=$ss dev_size_mb=90 > dev-name ||
|
|
+ skip_ 'failed to create scsi_debug device'
|
|
+dev=$(cat dev-name)
|
|
+
|
|
+mke2fs -F $dev
|
|
+parted -s "$dev" print > out 2>&1 || fail=1
|
|
+cat <<EOF > exp
|
|
+Model: Linux scsi_debug (scsi)
|
|
+Disk DEVICE: 94.4MB
|
|
+Sector size (logical/physical): ${ss}B/${ss}B
|
|
+Partition Table: loop
|
|
+Disk Flags:
|
|
+
|
|
+Number Start End Size File system Flags
|
|
+ 1 0.00B 94.4MB 94.4MB ext2
|
|
+
|
|
+EOF
|
|
+mv out o2 && sed -e "s,$dev,DEVICE,;" o2 > out
|
|
+
|
|
+compare exp out || fail=1
|
|
+parted -s $dev rm 1 || fail=1
|
|
+if [ -e ${dev}1 ]; then
|
|
+ echo "Partition should not exist on loop device"
|
|
+ fail=1
|
|
+fi
|
|
+partprobe $dev || fail=1
|
|
+if [ -e ${dev}1 ]; then
|
|
+ echo "Partition should not exist on loop device"
|
|
+ fail=1
|
|
+fi
|
|
+
|
|
+mount_point="`pwd`/mnt"
|
|
+
|
|
+# Be sure to unmount upon interrupt, failure, etc.
|
|
+cleanup_fn_() { umount "$mount_point" > /dev/null 2>&1; }
|
|
+
|
|
+# create mount point dir. and mount the just-created partition on it
|
|
+mkdir $mount_point || fail=1
|
|
+mount -t ext2 "${dev}" $mount_point || fail=1
|
|
+
|
|
+# now that a partition is mounted, mklabel attempt must fail
|
|
+parted -s "$dev" mklabel msdos > out 2>&1; test $? = 1 || fail=1
|
|
+
|
|
+# create expected output file
|
|
+echo "Error: Partition(s) on $dev are being used." > exp
|
|
+compare exp out || fail=1
|
|
+
|
|
+# make sure partition busy check works ( mklabel checks whole disk )
|
|
+parted -s "$dev" rm 1 > out 2>&1; test $? = 1 || fail=1
|
|
+# create expected output file
|
|
+echo "Error: Partition $dev is being used. You must unmount it before you modify \
|
|
+it with Parted." > exp
|
|
+compare exp out || fail=1
|
|
+
|
|
+umount "$mount_point"
|
|
+
|
|
+# make sure partprobe cleans up stale partition devices
|
|
+parted -s $dev mklabel msdos mkpart primary ext2 0% 100% || fail=1
|
|
+if [ ! -e ${dev}1 ]; then
|
|
+ echo "Partition doesn't exist on loop device"
|
|
+ fail=1
|
|
+fi
|
|
+
|
|
+mke2fs -F $dev
|
|
+partprobe $dev || fail=1
|
|
+if [ -e ${dev}1 ]; then
|
|
+ echo "Partition should not exist on loop device"
|
|
+ fail=1
|
|
+fi
|
|
+
|
|
+# make sure new loop label removes old partitions > 1
|
|
+parted -s $dev mklabel msdos mkpart primary ext2 0% 50% mkpart primary ext2 50% 100% || fail=1
|
|
+parted -s $dev mklabel loop || fail=1
|
|
+if [ -e ${dev}2 ]; then
|
|
+ echo "Partition 2 not removed"
|
|
+ fail=1
|
|
+fi
|
|
+
|
|
+Exit $fail
|
|
--
|
|
1.9.3
|
|
|