OSDN Git Service

[parted] Fix script mode support on mkfs commandline command
authorOtavio Salvador <otavio@ossystems.com.br>
Wed, 9 May 2007 19:03:39 +0000 (16:03 -0300)
committerOtavio Salvador <otavio@ossystems.com.br>
Wed, 9 May 2007 19:04:23 +0000 (16:04 -0300)
Parted was lacking support to script mode on do_mkfs method hence
always failing.

Note: tests/t2000-mkfs.sh was created to avoid it to happen again

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
parted/parted.c
tests/Makefile.am
tests/t2000-mkfs.sh [new file with mode: 0755]

index 99b9f28..d16ad96 100644 (file)
@@ -646,7 +646,7 @@ do_mkfs (PedDevice** dev)
         if (!disk)
                 goto error;
 
-        if  (!_partition_warn_loss())
+        if  (!opt_script_mode && !_partition_warn_loss())
                 goto error_destroy_disk;
 
         if (!command_line_get_partition (_("Partition number?"), disk, &part))
index 044e126..2948ae2 100644 (file)
@@ -1,6 +1,7 @@
 TESTS = \
   t0000-basic.sh \
-  t1000-mkpartfs.sh
+  t1000-mkpartfs.sh \
+  t2000-mkfs.sh
 
 TESTS_ENVIRONMENT = \
   PATH="`pwd`/../parted$(PATH_SEPARATOR)$$PATH"
diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh
new file mode 100755 (executable)
index 0000000..e47da8f
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+test_description='Create some file systems using mkfs.'
+
+. $srcdir/test-lib.sh
+
+N=40M
+dev=loop-file
+test_expect_success \
+    'create a file large enough to hold a fat32 file system' \
+    'dd if=/dev/zero of=$dev bs=$N count=1 2> /dev/null'
+
+test_expect_success \
+    'label the test disk' \
+    'parted -s $dev mklabel msdos > out 2>&1'
+test_expect_success 'expect no output' '$compare out /dev/null'
+
+test_expect_success \
+    'create an partition' \
+    'parted -s $dev mkpart primary 1 40 > out 2>&1'
+
+test_expect_success \
+    'create an msdos file system' \
+    'parted -s $dev mkfs 1 fat32 > out 2>&1'
+
+test_expect_success 'expect no output' '$compare out /dev/null'
+
+test_done