Module Name:    src
Committed By:   riz
Date:           Thu Dec  2 22:03:23 UTC 2010

Modified Files:
        src/tests/sbin/resize_ffs: t_resize_ffs.sh

Log Message:
Update existing test cases and add a couple more:

- PR bin/44177 is fixed
- test grow/shrink on a ffsv1 with 64k blocksize, which was broken until
  recently
- make sure the partial cylinder left over is big enough so it doesn't
  get thrown away now that resize_ffs properly uses the last cyl.

XXX TODO:  add tests which ensure data integrity.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/sbin/resize_ffs/t_resize_ffs.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/sbin/resize_ffs/t_resize_ffs.sh
diff -u src/tests/sbin/resize_ffs/t_resize_ffs.sh:1.1 src/tests/sbin/resize_ffs/t_resize_ffs.sh:1.2
--- src/tests/sbin/resize_ffs/t_resize_ffs.sh:1.1	Tue Nov 30 23:17:27 2010
+++ src/tests/sbin/resize_ffs/t_resize_ffs.sh	Thu Dec  2 22:03:23 2010
@@ -1,4 +1,4 @@
-# $NetBSD: t_resize_ffs.sh,v 1.1 2010/11/30 23:17:27 riz Exp $
+# $NetBSD: t_resize_ffs.sh,v 1.2 2010/12/02 22:03:23 riz Exp $
 #
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -33,13 +33,14 @@
 
 # misc routines
 
-atf_test_case grow cleanup
-grow_head()
+atf_test_case grow_ffsv1_partial_cg cleanup
+grow_ffsv1_partial_cg_head()
 {
-	atf_set "descr" "Checks successful fs growth"
+	atf_set "descr" "Checks successful ffsv1 growth by less" \
+			"than a cylinder group"
 	atf_set "require.user"	"root"
 }
-grow_body()
+grow_ffsv1_partial_cg_body()
 {
 	cat >disktab <<EOF
 floppy288|2.88MB 3.5in Extra High Density Floppy:\
@@ -55,24 +56,92 @@
 	atf_check -o ignore -e ignore vnconfig -v ${VND} ${IMG}
 	atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} floppy288
 	# resize_ffs only supports ffsv1 at the moment
-	atf_check -o ignore -e ignore newfs -V1 -s 3000 /dev/r${VND}a
+	atf_check -o ignore -e ignore newfs -V1 -s 4000 /dev/r${VND}a
 
 	# grow the fs to the full partition size (5760)
 	atf_check -s exit:0 resize_ffs -y /dev/r${VND}a
 	atf_check -s exit:0 -o ignore fsck -f -n /dev/r${VND}a
 }
-grow_cleanup()
+grow_ffsv1_partial_cg_cleanup()
 {
 	vnconfig -u ${VND}
 }
 
-atf_test_case shrink cleanup
-shrink_head()
+atf_test_case grow_ffsv1_64k cleanup
+grow_ffsv1_64k()
 {
-	atf_set "descr" "Checks successful fs shrinkage"
+	atf_set "descr" "Checks successful ffsv1 growth with 64k blocksize"
 	atf_set "require.user"	"root"
 }
-shrink_body()
+grow_ffsv1_64k_body()
+{
+	cat >disktab <<EOF
+disk64M|64MB test disk:\
+	:ty=test:se#512:nt#64:ns#32:nc#64:\
+	:pa#131072:oa#0:ba#65536:fa#8192:ta=4.2BSD:\
+	:pc#131072:oc#0:\
+	:pd#131072:od#0:
+EOF
+
+	echo "***resize_ffs grow 64k block test"
+
+	atf_check -o ignore -e ignore dd if=/dev/zero of=${IMG} count=131072
+	atf_check -o ignore -e ignore vnconfig -v ${VND} ${IMG}
+	atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} disk64M
+	atf_check -o ignore -e ignore newfs -V1 -b 65536 -f 8192 \
+		-s 32768 /dev/r${VND}a
+
+	# grow the fs to the full partition size (131072)
+	atf_check -s exit:0 resize_ffs -y /dev/r${VND}a
+	atf_check -s exit:0 -o ignore fsck -f -n /dev/r${VND}a
+	atf_check -o match:'size[[:space:]]*8192' dumpfs /dev/r${VND}a
+}
+grow_ffsv1_64k_cleanup()
+{
+	vnconfig -u ${VND}
+}
+
+atf_test_case shrink_ffsv1_64k cleanup
+shrink_ffsv1_64k()
+{
+	atf_set "descr" "Checks successful ffsv1 shrinkage with 64k blocksize"
+	atf_set "require.user"	"root"
+}
+shrink_ffsv1_64k_body()
+{
+	cat >disktab <<EOF
+disk64M|64MB test disk:\
+	:ty=test:se#512:nt#64:ns#32:nc#64:\
+	:pa#131072:oa#0:ba#65536:fa#8192:ta=4.2BSD:\
+	:pc#131072:oc#0:\
+	:pd#131072:od#0:
+EOF
+
+	echo "***resize_ffs shrink 64k block test"
+
+	atf_check -o ignore -e ignore dd if=/dev/zero of=${IMG} count=131072
+	atf_check -o ignore -e ignore vnconfig -v ${VND} ${IMG}
+	atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} disk64M
+	atf_check -o ignore -e ignore newfs -V1 -b 65536 -f 8192 /dev/r${VND}a
+
+	# shrink it to half size
+	atf_check -s exit:0 resize_ffs -y -s 65536 /dev/r${VND}a
+	atf_check -s exit:0 -o ignore fsck -f -n /dev/r${VND}a
+	atf_check -o match:'size[[:space:]]*4096' dumpfs /dev/r${VND}a
+}
+shrink_ffsv1_64k_cleanup()
+{
+	vnconfig -u ${VND}
+}
+
+atf_test_case shrink_ffsv1_partial_cg cleanup
+shrink_ffsv1_partial_cg_head()
+{
+	atf_set "descr" "Checks successful shrinkage of ffsv1 by" \
+			"less than a cylinder group"
+	atf_set "require.user"	"root"
+}
+shrink_ffsv1_partial_cg_body()
 {
 	cat >disktab <<EOF
 floppy288|2.88MB 3.5in Extra High Density Floppy:\
@@ -82,27 +151,27 @@
 	:pc#5760:oc#0:
 EOF
 
-	echo "*** resize_ffs shrinkage test"
+	echo "*** resize_ffs shrinkage partial cg test"
 
 	atf_check -o ignore -e ignore dd if=/dev/zero of=${IMG} count=5860
 	atf_check -o ignore -e ignore vnconfig -v ${VND} ${IMG}
 	atf_check -o ignore -e ignore disklabel -f disktab -rw ${VND} floppy288
-	# resize_ffs only supports ffsv1 at the moment
 	atf_check -o ignore -e ignore newfs -V1 /dev/r${VND}a
 
 	# shrink the fs to something smaller.  Would be better to have
 	# data in there, but one step at a time
-	atf_check -s exit:0 resize_ffs -s 3000 -y /dev/r${VND}a
-	atf_expect_fail "PR bin/44177"
+	atf_check -s exit:0 resize_ffs -s 4000 -y /dev/r${VND}a
 	atf_check -s exit:0 -o ignore fsck -f -n /dev/r${VND}a
 }
-shrink_cleanup()
+shrink_ffsv1_partial_cg_cleanup()
 {
 	vnconfig -u ${VND}
 }
 
 atf_init_test_cases()
 {
-	atf_add_test_case grow
-	atf_add_test_case shrink
+	atf_add_test_case grow_ffsv1_partial_cg
+	atf_add_test_case grow_ffsv1_64k
+	atf_add_test_case shrink_ffsv1_partial_cg
+	atf_add_test_case shrink_ffsv1_64k
 }

Reply via email to