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

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