Before committing to support FAT file system resizing,
I wanted to write a few tests.  So far, I've been stumped.
I've used the test script below, invoking it like this,
on an old 64MB USB key:

  sudo env DEVICE_TO_ERASE=/dev/sdd DEVICE_TO_ERASE_SIZE=66.0MB \
    ./t3000*.sh --debug --verbose

But it always fails with this:

    * expecting success: parted -s $dev resize 1 50s 71000s
    Error: Could not detect file system.

That's not so bad, and may well be due to my >512-byte sector changes
breaking the FS-recognition code.  However, even when I tried to resize
using Fedora's parted-1.8.8-17.fc11.x86_64, it still fails consistently.

I tried this, against the partition table and FS created by the test:

    for i in $(seq 70100 3 71000); do \
      echo $i; parted /dev/sdd resize 1 50s ${i}s && break; done

For every single iteration, it failed with this diagnostic:

    No Implementation: GNU Parted cannot resize this partition to this size.\
    We're working on it!

Does anyone use parted's FAT resizing capability?
For now, I'm going to assume "No" and remove it.

Speak up if you can demonstrate that parted's FAT resizing works.



>From c8cb7d4193c07b2d7637f4763c71486f19749b84 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Sat, 19 Sep 2009 08:22:20 +0200
Subject: [PATCH] tests: attempt to resize a FAT file system

* tests/t3000-resize-fat.sh: New file.
---
 tests/t3000-resize-fat.sh |   66 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100755 tests/t3000-resize-fat.sh

diff --git a/tests/t3000-resize-fat.sh b/tests/t3000-resize-fat.sh
new file mode 100755
index 0000000..496e15f
--- /dev/null
+++ b/tests/t3000-resize-fat.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# Copyright (C) 2009 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 3 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, see <http://www.gnu.org/licenses/>.
+
+test_description='exercise the resize sub-command'
+
+: ${srcdir=.}
+. $srcdir/test-lib.sh
+
+require_512_byte_sector_size_
+dev=$DEVICE_TO_ERASE
+
+N=62M
+
+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 FAT partition' \
+    'parted -s $dev mkpart primary fat32 50s 70000s > out 2>&1'
+test_expect_success 'expect no output' 'compare out /dev/null'
+
+test_expect_success \
+    'print partition table' \
+    'parted -m -s $dev u b p > out 2>&1'
+
+# FIXME: check expected output
+
+# There's a race condition here: on udev-based systems, the partition#1
+# 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'
+
+test_expect_success \
+    'create the file system' \
+    'mkfs.vfat -F 32 ${dev}1'
+
+test_expect_success \
+    'resize that file system' \
+    'parted -s $dev resize 1 50s 71000s'
+
+test_expect_success \
+    'print partition table' \
+    'parted -m -s $dev u b p'
+
+test_done
--
1.6.5.rc2.177.ga9dd6

_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel

Reply via email to