Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests Add some basic tests of resize_ffs(8). The 'grow' tes...



details:   https://anonhg.NetBSD.org/src/rev/a3b3fe87beb2
branches:  trunk
changeset: 759183:a3b3fe87beb2
user:      riz <riz%NetBSD.org@localhost>
date:      Tue Nov 30 23:17:27 2010 +0000

description:
Add some basic tests of resize_ffs(8).  The 'grow' test does nothing
more than create an empty file system, grow it, and makes sure fsck
finds the result clean.  The 'shrink' test does likewise for shrinking,
but is an expected failure at the moment due to PR bin/44177.

diffstat:

 tests/Makefile                        |    4 +-
 tests/sbin/Makefile                   |   10 +++
 tests/sbin/Makefile.inc               |    1 +
 tests/sbin/resize_ffs/Makefile        |    9 ++
 tests/sbin/resize_ffs/t_resize_ffs.sh |  108 ++++++++++++++++++++++++++++++++++
 5 files changed, 130 insertions(+), 2 deletions(-)

diffs (162 lines):

diff -r 693b5c364d8b -r a3b3fe87beb2 tests/Makefile
--- a/tests/Makefile    Tue Nov 30 22:32:01 2010 +0000
+++ b/tests/Makefile    Tue Nov 30 23:17:27 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.23 2010/08/04 13:15:15 pooka Exp $
+# $NetBSD: Makefile,v 1.24 2010/11/30 23:17:27 riz Exp $
 
 .include <bsd.own.mk>
 
@@ -8,7 +8,7 @@
 SUBDIR=        crypto games ipf util
   
 .if ${MKATF} != "no"
-SUBDIR+= dev fs include kernel lib libexec net rump sys syscall
+SUBDIR+= dev fs include kernel lib libexec net rump sbin sys syscall
 
 . if ${MACHINE} != "evbppc" && ${MKKMOD} != "no"
 SUBDIR+= modules
diff -r 693b5c364d8b -r a3b3fe87beb2 tests/sbin/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sbin/Makefile       Tue Nov 30 23:17:27 2010 +0000
@@ -0,0 +1,10 @@
+#      $NetBSD: Makefile,v 1.1 2010/11/30 23:17:27 riz Exp $
+#
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/sbin
+
+TESTS_SUBDIRS+=        resize_ffs
+
+.include <bsd.test.mk>
diff -r 693b5c364d8b -r a3b3fe87beb2 tests/sbin/Makefile.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sbin/Makefile.inc   Tue Nov 30 23:17:27 2010 +0000
@@ -0,0 +1,1 @@
+.include "../Makefile.inc"
diff -r 693b5c364d8b -r a3b3fe87beb2 tests/sbin/resize_ffs/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sbin/resize_ffs/Makefile    Tue Nov 30 23:17:27 2010 +0000
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2010/11/30 23:17:27 riz Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/sbin/resize_ffs
+
+TESTS_SH=      t_resize_ffs
+
+.include <bsd.test.mk>
diff -r 693b5c364d8b -r a3b3fe87beb2 tests/sbin/resize_ffs/t_resize_ffs.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/sbin/resize_ffs/t_resize_ffs.sh     Tue Nov 30 23:17:27 2010 +0000
@@ -0,0 +1,108 @@
+# $NetBSD: t_resize_ffs.sh,v 1.1 2010/11/30 23:17:27 riz Exp $
+#
+# Copyright (c) 2010 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Jeffrey C. Rizzo.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+IMG=diskimage
+VND=vnd0
+
+# misc routines
+
+atf_test_case grow cleanup
+grow_head()
+{
+       atf_set "descr" "Checks successful fs growth"
+       atf_set "require.user"  "root"
+}
+grow_body()
+{
+       cat >disktab <<EOF
+floppy288|2.88MB 3.5in Extra High Density Floppy:\
+       :ty=floppy:se#512:nt#2:rm#300:ns#36:nc#80:\
+       :pa#5760:oa#0:ba#4096:fa#512:ta=4.2BSD:\
+       :pb#5760:ob#0:\
+       :pc#5760:oc#0:
+EOF
+
+       echo "***resize_ffs grow 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 -s 3000 /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()
+{
+       vnconfig -u ${VND}
+}
+
+atf_test_case shrink cleanup
+shrink_head()
+{
+       atf_set "descr" "Checks successful fs shrinkage"
+       atf_set "require.user"  "root"
+}
+shrink_body()
+{
+       cat >disktab <<EOF
+floppy288|2.88MB 3.5in Extra High Density Floppy:\
+       :ty=floppy:se#512:nt#2:rm#300:ns#36:nc#80:\
+       :pa#5760:oa#0:ba#4096:fa#512:ta=4.2BSD:\
+       :pb#5760:ob#0:\
+       :pc#5760:oc#0:
+EOF
+
+       echo "*** resize_ffs shrinkage 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 -o ignore fsck -f -n /dev/r${VND}a
+}
+shrink_cleanup()
+{
+       vnconfig -u ${VND}
+}
+
+atf_init_test_cases()
+{
+       atf_add_test_case grow
+       atf_add_test_case shrink
+}



Home | Main Index | Thread Index | Old Index