Blame SOURCES/0047-tests-excersise-resize-command.patch

2a8729
From f1711f8bd420315a01b2df6d4339646c96169558 Mon Sep 17 00:00:00 2001
2a8729
From: Petr Uzel <petr.uzel@suse.cz>
2a8729
Date: Tue, 27 Sep 2011 09:11:29 +0200
2a8729
Subject: [PATCH 47/48] tests: excersise resize command
2a8729
2a8729
a lot of TODOs
2a8729
2a8729
(cherry picked from commit 33fd692cb14045fdc13306cd57cfe2040328daa8)
2a8729
---
2a8729
 tests/Makefile.am               |  1 +
2a8729
 tests/t3200-resize-partition.sh | 89 +++++++++++++++++++++++++++++++++++++++++
2a8729
 2 files changed, 90 insertions(+)
2a8729
 create mode 100755 tests/t3200-resize-partition.sh
2a8729
2a8729
diff --git a/tests/Makefile.am b/tests/Makefile.am
2a8729
index 1cf859c..29fa280 100644
2a8729
--- a/tests/Makefile.am
2a8729
+++ b/tests/Makefile.am
2a8729
@@ -42,6 +42,7 @@ TESTS = \
2a8729
   t2400-dos-hfs-partition-type.sh \
2a8729
   t2500-probe-corrupt-hfs.sh \
2a8729
   t3000-resize-fs.sh \
2a8729
+  t3200-resize-partition.sh \
2a8729
   t3200-type-change.sh \
2a8729
   t3300-palo-prep.sh \
2a8729
   t3310-flags.sh \
2a8729
diff --git a/tests/t3200-resize-partition.sh b/tests/t3200-resize-partition.sh
2a8729
new file mode 100755
2a8729
index 0000000..251b545
2a8729
--- /dev/null
2a8729
+++ b/tests/t3200-resize-partition.sh
2a8729
@@ -0,0 +1,89 @@
2a8729
+#!/bin/sh
2a8729
+# exercise the resize sub-command
2a8729
+# based on t3000-resize-fs.sh test
2a8729
+
2a8729
+# Copyright (C) 2009-2011 Free Software Foundation, Inc.
2a8729
+
2a8729
+# This program is free software; you can redistribute it and/or modify
2a8729
+# it under the terms of the GNU General Public License as published by
2a8729
+# the Free Software Foundation; either version 3 of the License, or
2a8729
+# (at your option) any later version.
2a8729
+
2a8729
+# This program is distributed in the hope that it will be useful,
2a8729
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2a8729
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2a8729
+# GNU General Public License for more details.
2a8729
+
2a8729
+# You should have received a copy of the GNU General Public License
2a8729
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2a8729
+
2a8729
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
2a8729
+
2a8729
+require_root_
2a8729
+require_scsi_debug_module_
2a8729
+
2a8729
+ss=$sector_size_
2a8729
+
2a8729
+default_start=1024s
2a8729
+default_end=2048s
2a8729
+
2a8729
+# create memory-backed device
2a8729
+scsi_debug_setup_ dev_size_mb=5 > dev-name ||
2a8729
+  skip_ 'failed to create scsi_debug device'
2a8729
+dev=$(cat dev-name)
2a8729
+
2a8729
+# TODO test simple shrink
2a8729
+# TODO test expand past end of the disk
2a8729
+# TODO test expand past begin of next partition
2a8729
+# TODO test shrink before start
2a8729
+# TODO test everything with GPT
2a8729
+# TODO more tests with extended/logical partitions
2a8729
+
2a8729
+parted -s $dev mklabel msdos > out 2> err || fail=1
2a8729
+# expect no output
2a8729
+compare /dev/null out || fail=1
2a8729
+compare /dev/null err || fail=1
2a8729
+
2a8729
+# ensure that the disk is large enough
2a8729
+dev_n_sectors=$(parted -s $dev u s p|sed -n '2s/.* \([0-9]*\)s$/\1/p')
2a8729
+device_sectors_required=$(echo $default_end | sed 's/s$//')
2a8729
+# Ensure that $dev is large enough for this test
2a8729
+test $device_sectors_required -le $dev_n_sectors || fail=1
2a8729
+
2a8729
+# create an empty partition
2a8729
+parted -a minimal -s $dev mkpart primary $default_start $default_end > out 2>&1 || fail=1
2a8729
+compare /dev/null out || fail=1
2a8729
+
2a8729
+# print partition table
2a8729
+parted -m -s $dev u s p > out 2>&1 || fail=1
2a8729
+
2a8729
+# FIXME: check expected output
2a8729
+
2a8729
+# wait for new partition device to appear
2a8729
+wait_for_dev_to_appear_ ${dev}1 || { warn_ "${dev}1 did not appear"  fail=1; }
2a8729
+sleep 1
2a8729
+
2a8729
+
2a8729
+# extend the filesystem to end on sector 4096
2a8729
+new_end=4096s
2a8729
+parted -s $dev resizepart 1 $new_end > out 2> err || fail=1
2a8729
+# expect no output
2a8729
+compare /dev/null out || fail=1
2a8729
+compare /dev/null err || fail=1
2a8729
+
2a8729
+# print partition table
2a8729
+parted -m -s $dev u s p > out 2>&1 || fail=1
2a8729
+
2a8729
+sed -n 3p out > k && mv k out || fail=1
2a8729
+printf "1:$default_start:$new_end:3073s:::$ms;\n" > exp || fail=1
2a8729
+compare exp out || fail=1
2a8729
+
2a8729
+# Remove the partition explicitly, so that mklabel doesn't evoke a warning.
2a8729
+parted -s $dev rm 1 || fail=1
2a8729
+
2a8729
+# Create a clean partition table for the next iteration.
2a8729
+parted -s $dev mklabel msdos > out 2>&1 || fail=1
2a8729
+# expect no output
2a8729
+compare /dev/null out || fail=1
2a8729
+
2a8729
+Exit $fail
2a8729
-- 
2a8729
2.9.4
2a8729