Blame SOURCES/0096-tests-Add-a-test-for-resizepart-on-a-busy-partition.patch

b268e8
From 97113adc42f15ba04630c2808f14cd01aff22ed9 Mon Sep 17 00:00:00 2001
b268e8
From: "Brian C. Lane" <bcl@redhat.com>
b268e8
Date: Tue, 1 Sep 2020 14:51:54 -0700
b268e8
Subject: [PATCH 96/97] tests: Add a test for resizepart on a busy partition
b268e8
b268e8
This makes sure that the resizepart on a busy partition with the size on
b268e8
the cmdline will work.
b268e8
b268e8
(cherry picked from commit dfc611bd5126840d68493ad0e761511a71325af7)
b268e8
b268e8
Related: rhbz#1861804
b268e8
---
b268e8
 tests/t3200-resize-partition.sh | 44 ++++++++++++++++++++++++++++++---
b268e8
 1 file changed, 40 insertions(+), 4 deletions(-)
b268e8
b268e8
diff --git a/tests/t3200-resize-partition.sh b/tests/t3200-resize-partition.sh
b268e8
index dcf1775..2200977 100755
b268e8
--- a/tests/t3200-resize-partition.sh
b268e8
+++ b/tests/t3200-resize-partition.sh
b268e8
@@ -2,7 +2,7 @@
b268e8
 # exercise the resize sub-command
b268e8
 # based on t3000-resize-fs.sh test
b268e8
 
b268e8
-# Copyright (C) 2009-2011 Free Software Foundation, Inc.
b268e8
+# Copyright (C) 2009-2020 Free Software Foundation, Inc.
b268e8
 
b268e8
 # This program is free software; you can redistribute it and/or modify
b268e8
 # it under the terms of the GNU General Public License as published by
b268e8
@@ -66,8 +66,8 @@ sleep 1
b268e8
 # Running it without end should not core-dump or prompt
b268e8
 parted -s $dev resizepart 1 > out 2> err || fail=1
b268e8
 
b268e8
-# extend the filesystem to end on sector 4096
b268e8
-new_end=4096s
b268e8
+# extend the filesystem to end on sector 2048
b268e8
+new_end=2048s
b268e8
 parted -s $dev resizepart 1 $new_end > out 2> err || fail=1
b268e8
 # expect no output
b268e8
 compare /dev/null out || fail=1
b268e8
@@ -77,9 +77,45 @@ compare /dev/null err || fail=1
b268e8
 parted -m -s $dev u s p > out 2>&1 || fail=1
b268e8
 
b268e8
 sed -n 3p out > k && mv k out || fail=1
b268e8
-printf "1:$default_start:$new_end:3073s:::$ms;\n" > exp || fail=1
b268e8
+printf "1:$default_start:$new_end:1025s:::$ms;\n" > exp || fail=1
b268e8
 compare exp out || fail=1
b268e8
 
b268e8
+## Make sure resizing a busy partition works when user answers 'yes'
b268e8
+# Format the partition and mount it for the busy check
b268e8
+mkfs.ext4 "${dev}1" || skip_ mkfs.ext4 failed
b268e8
+
b268e8
+# be sure to unmount upon interrupt, failure, etc.
b268e8
+cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; }
b268e8
+
b268e8
+mount_point=$(pwd)/mnt
b268e8
+
b268e8
+mkdir $mount_point || fail=1
b268e8
+mount "${dev}1" "$mount_point" || fail=1
b268e8
+
b268e8
+# extend the filesystem to end on sector 4096
b268e8
+new_end=4096s
b268e8
+echo yes | parted ---pretend-input-tty $dev resizepart 1 $new_end > out 2>&1
b268e8
+cat > exp <
b268e8
+Warning: Partition ${dev}1 is being used. Are you sure you want to continue?
b268e8
+Yes/No? yes
b268e8
+Information: You may need to update /etc/fstab.
b268e8
+
b268e8
+EOF
b268e8
+# Transform the actual output, to avoid spurious differences when
b268e8
+# $PWD contains a symlink-to-dir.  Also, remove the ^M      ...^M bogosity.
b268e8
+# normalize the actual output
b268e8
+mv out o2 && sed -e "s,
   *
,,g;s, $,," o2 > out
b268e8
+compare exp out || fail=1
b268e8
+
b268e8
+# print partition table
b268e8
+parted -m -s $dev u s p > out 2>&1 || fail=1
b268e8
+
b268e8
+sed -n 3p out > k && mv k out || fail=1
b268e8
+printf "1:$default_start:$new_end:3073s:ext2::$ms;\n" > exp || fail=1
b268e8
+compare exp out || fail=1
b268e8
+
b268e8
+umount "${dev}1" || fail=1
b268e8
+
b268e8
 # Remove the partition explicitly, so that mklabel doesn't evoke a warning.
b268e8
 parted -s $dev rm 1 || fail=1
b268e8
 
b268e8
-- 
b268e8
2.31.1
b268e8