summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/t-local.sh6
-rwxr-xr-xtests/t0010-script-no-ctrl-chars.sh36
-rw-r--r--tests/t0400-loop-clobber-infloop.sh27
-rwxr-xr-xtests/t3000-resize-fs.sh105
4 files changed, 101 insertions, 73 deletions
diff --git a/tests/t-local.sh b/tests/t-local.sh
index de134e3..096e67c 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -91,4 +91,10 @@ scsi_debug_setup_()
return 0
}
+require_512_byte_sector_size_()
+{
+ test $sector_size_ = 512 \
+ || skip_test_ FS test with sector size != 512
+}
+
. $srcdir/t-lvm.sh
diff --git a/tests/t0010-script-no-ctrl-chars.sh b/tests/t0010-script-no-ctrl-chars.sh
index 9862eea..2fbc19d 100755
--- a/tests/t0010-script-no-ctrl-chars.sh
+++ b/tests/t0010-script-no-ctrl-chars.sh
@@ -16,35 +16,31 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-test_description='--script does no readline initialization'
+if test "$VERBOSE" = yes; then
+ set -x
+ parted --version
+fi
: ${srcdir=.}
-. $srcdir/test-lib.sh
+. $srcdir/t-lib.sh
ss=$sector_size_
n_sectors=5000
dev=loop-file
-test_expect_success \
- 'create the test file' \
- 'dd if=/dev/null of=$dev bs=$ss seek=$n_sectors'
+fail=0
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
-test_expect_success \
- 'run parted -s FILE mklabel msdos' \
- 'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'expect no output' 'compare out /dev/null'
+parted -s $dev mklabel msdos > out 2>&1 || fail=1
+# expect no output
+compare out /dev/null || fail=1
-test_expect_success \
- 'print partition table in --script mode' \
- 'TERM=xterm parted -m -s $dev u s p > out 2>&1'
+# print partition table in --script mode
+TERM=xterm parted -m -s $dev u s p > out 2>&1 || fail=1
-ok=0
-sed "s,.*/$dev:,$dev:," out > k && mv k out &&
-printf "BYT;\n$dev:${n_sectors}s:file:$ss:$ss:msdos:;\n" > exp &&
- ok=1
+sed "s,.*/$dev:,$dev:," out > k && mv k out || fail=1
+printf "BYT;\n$dev:${n_sectors}s:file:$ss:$ss:msdos:;\n" > exp || fail=1
-test_expect_success \
- 'match against expected output' \
- 'test $ok = 1 && compare out exp'
+compare out exp || fail=1
-test_done
+Exit $fail
diff --git a/tests/t0400-loop-clobber-infloop.sh b/tests/t0400-loop-clobber-infloop.sh
index 824c410..185f91e 100644
--- a/tests/t0400-loop-clobber-infloop.sh
+++ b/tests/t0400-loop-clobber-infloop.sh
@@ -1,4 +1,5 @@
#!/bin/sh
+# do not infloop in loop_clobber
# Copyright (C) 2009 Free Software Foundation, Inc.
@@ -15,25 +16,25 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-test_description='do not infloop in loop_clobber'
+if test "$VERBOSE" = yes; then
+ set -x
+ parted --version
+fi
: ${srcdir=.}
-. $srcdir/test-lib.sh
+. $srcdir/t-lib.sh
N=1M
dev=loop-file
-test_expect_success \
- 'create a file large enough to hold a partition table' \
- 'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
+fail=0
+dd if=/dev/null of=$dev bs=1 seek=$N || fail=1
-test_expect_success \
- 'create a swap partition in the entire device' \
- 'mkswap $dev'
+mkswap $dev || fail=1
# There was a small interval (no release) during which this would infloop.
-test_expect_success \
- 'create a dos partition table' \
- 'parted -s $dev mklabel msdos > out 2>&1'
-test_expect_success 'expect no output' 'compare out /dev/null'
+# create a dos partition table
+parted -s $dev mklabel msdos > out 2>&1 || fail=1
-test_done
+compare out /dev/null || fail=1
+
+Exit $fail
diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
index 0620a5e..c338be8 100755
--- a/tests/t3000-resize-fs.sh
+++ b/tests/t3000-resize-fs.sh
@@ -1,4 +1,5 @@
#!/bin/sh
+# exercise the resize sub-command; FAT and HFS only
# Copyright (C) 2009 Free Software Foundation, Inc.
@@ -15,42 +16,59 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-test_description='exercise the resize sub-command; FAT and HFS only'
+if test "$VERBOSE" = yes; then
+ set -x
+ parted --version
+fi
: ${srcdir=.}
-. $srcdir/test-lib.sh
+. $srcdir/t-lib.sh
+require_root_
+require_scsi_debug_module_
require_512_byte_sector_size_
-dev=$DEVICE_TO_ERASE
-sz=$DEVICE_TO_ERASE_SIZE
+
+cat <<EOF > exp-warning || framework_failure
+WARNING: you are attempting to use parted to operate on (resize) a file system.
+parted's file system manipulation code is not as robust as what you'll find in
+dedicated, file-system-specific packages like e2fsprogs. We recommend
+you use parted only to manipulate partition tables, whenever possible.
+Support for performing most operations on most types of file systems
+will be removed in an upcoming release.
+EOF
+
ss=$sector_size_
start=63s
default_end=546147s
new_end=530144s
+# create memory-backed device
+scsi_debug_setup_ dev_size_mb=550 > dev-name ||
+ skip_test_ 'failed to create scsi_debug device'
+dev=$(cat dev-name)
+
+fail=0
+
+parted -s $dev mklabel gpt > out 2>&1 || fail=1
+# expect no output
+compare out /dev/null || fail=1
+
# ensure that the disk is large enough
dev_n_sectors=$(parted -s $dev u s p|sed -n '2s/.* \([0-9]*\)s$/\1/p')
device_sectors_required=$(echo $default_end | sed 's/s$//')
-test_expect_success \
- "whether $dev is large enough for this test" \
- 'test $device_sectors_required -le $dev_n_sectors'
+# Ensure that $dev is large enough for this test
+test $device_sectors_required -le $dev_n_sectors || fail=1
for fs_type in hfs+ fat32; do
- test_expect_success \
- 'create a partition table' \
- 'parted -s $dev mklabel gpt > out 2>&1'
- test_expect_success 'expect no output' 'compare out /dev/null'
-
- test_expect_success \
- "create an empty $fs_type partition, cylinder aligned, size > 256 MB" \
- 'parted -s $dev mkpart primary $fs_type $start $default_end > out 2>&1'
- test_expect_success 'expect no output' 'compare out /dev/null'
+ # create an empty $fs_type partition, cylinder aligned, size > 256 MB
+ parted -s $dev mkpart primary $fs_type $start $default_end > out 2>&1 || fail=1
+ # expect no output
+ compare out /dev/null || fail=1
- test_expect_success \
- 'print partition table' \
- 'parted -m -s $dev u s p > out 2>&1'
+ # print partition table
+ parted -m -s $dev u s p > out 2>&1 || fail=1
# FIXME: check expected output
@@ -58,11 +76,15 @@ for fs_type in hfs+ fat32; do
# device, ${dev}1 (i.e., /dev/sde1) is not created immediately, and
# without some delay, this mount command would fail. Using a flash card
# as $dev, the loop below typically iterates 7-20 times.
- test_expect_success \
- 'wait for new partition device to appear' \
- 'i=0; while :; do
- test -e "${dev}1" && break; test $i = 90 && break;
- i=$(expr $i + 1); done; test $i != 90'
+
+ # wait for new partition device to appear
+ i=0
+ while :; do
+ test -e "${dev}1" && break; test $i = 90 && break;
+ i=$(expr $i + 1)
+ sleep .01 2>/dev/null || sleep 1
+ done
+ test $i = 90 && fail=1
case $fs_type in
fat32) mkfs_cmd='mkfs.vfat -F 32';;
@@ -70,26 +92,29 @@ for fs_type in hfs+ fat32; do
*) error "internal error: unhandled fs type: $fs_type";;
esac
- test_expect_success \
- 'create the file system' \
- '$mkfs_cmd ${dev}1'
+ # create the file system
+ $mkfs_cmd ${dev}1 || fail=1
# NOTE: shrinking is the only type of resizing that works.
- test_expect_success \
- 'resize that file system to be one cylinder (8MiB) smaller' \
- 'parted -s $dev resize 1 $start $new_end > out 2>&1'
- test_expect_success 'expect no output' 'compare out /dev/null'
+ # resize that file system to be one cylinder (8MiB) smaller
+ parted -s $dev resize 1 $start $new_end > out 2> err || fail=1
+ # expect no output
+ compare out /dev/null || fail=1
+ compare err exp-warning || fail=1
+
+ # print partition table
+ parted -m -s $dev u s p > out 2>&1 || fail=1
- test_expect_success \
- 'print partition table' \
- 'parted -m -s $dev u s p > out 2>&1'
+ # compare against expected output
+ sed -n 3p out > k && mv k out || fail=1
+ printf "1:$start:$new_end:530082s:$fs_type:primary:$ms;\n" > exp || fail=1
+ compare out exp || fail=1
- test_expect_success \
- 'compare against expected output' \
- 'sed -n 3p out > k && mv k out &&
- printf "1:$start:$new_end:530082s:$fs_type:primary:$ms;\n" > exp &&
- compare out exp'
+ # Create a clean partition table for the next iteration.
+ parted -s $dev mklabel gpt > out 2>&1 || fail=1
+ # expect no output
+ compare out /dev/null || fail=1
done
-test_done
+Exit $fail