[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Jim Meyering meyering at alioth.debian.org
Fri Nov 4 20:58:57 UTC 2011


 tests/t-lib-helpers.sh     |   15 +++++++++++++++
 tests/t9030-align-check.sh |   10 +++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)

New commits:
commit 021774cd30af313afdeb6ba7f71b479f5f2e52b1
Author: Brian C. Lane <bcl at redhat.com>
Date:   Fri Oct 21 13:46:53 2011 -0700

    tests: t9030 wait for partition removal
    
    The removal of the partition may take enough time that the next
    mkpart will fail.  Wait for it to be removed.
    
    Remove scsi_debug size and set the end of the partition to 800s so that
    it will fit inside the default scsi_debug size of 8M, even when sector
    size is 4Kb. This prevents failures on machines with limited memory.
    
    * tests/t9030-align-check.sh: Wait for partition removal and use
    a smaller disk.

diff --git a/tests/t9030-align-check.sh b/tests/t9030-align-check.sh
index bc8ae09..ac80137 100644
--- a/tests/t9030-align-check.sh
+++ b/tests/t9030-align-check.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# exercise the new align-check command
+# exercise the align-check command
 
 # Copyright (C) 2009-2011 Free Software Foundation, Inc.
 
@@ -17,6 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
+ss=$sector_size_
 
 require_root_
 require_scsi_debug_module_
@@ -25,7 +26,7 @@ grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
   skip_ 'this system lacks a new-enough libblkid'
 
 # create memory-backed device
-scsi_debug_setup_ dev_size_mb=550 physblk_exp=3 lowest_aligned=7 > dev-name ||
+scsi_debug_setup_ physblk_exp=3 lowest_aligned=7 sector_size=$ss > dev-name ||
   skip_ 'failed to create scsi_debug device'
 scsi_dev=$(cat dev-name)
 p1=${scsi_dev}1
@@ -34,7 +35,7 @@ parted -s $scsi_dev mklabel gpt || fail=1
 
 i=60
 while :; do
-  parted -s $scsi_dev mkpart p1 ext2 ${i}s 80000s || fail=1
+  parted -s $scsi_dev mkpart p1 ext2 ${i}s 800s || fail=1
   wait_for_dev_to_appear_ $p1 || fail=1
   parted -s $scsi_dev align-check min 1 > out 2>&1
   result=$?
@@ -46,6 +47,9 @@ while :; do
   parted -s $scsi_dev rm 1
   i=$(expr $i + 1)
   test $i = 70 && break
+
+  # Wait up to 10s for the partition file to disappear.
+  wait_for_dev_to_disappear_ $p1 10 || { fail=1; warn $p1 failed to disappear; }
 done
 
 Exit $fail

commit 2ecc299070da4a6c4db0c7c5a84da990a07cd095
Author: Jim Meyering <meyering at redhat.com>
Date:   Fri Nov 4 21:28:51 2011 +0100

    tests: add a helper function
    
    * tests/t-lib-helpers.sh (wait_for_dev_to_disappear_): New function.

diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index bb41139..3c41e7b 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -378,6 +378,21 @@ wait_for_dev_to_appear_()
   return 1
 }
 
+# Like the above, but don't hard-code the max timeout.
+wait_for_dev_to_disappear_()
+{
+  local file=$1
+  local n_sec=$2
+  local i=0
+  local incr=1
+  while :; do
+    ls "$file" > /dev/null 2>&1 || return 0
+    sleep .1 2>/dev/null || { sleep 1; incr=10; }
+    i=$(expr $i + $incr); test $i -ge $($n_sec \* 10) && break
+  done
+  return 1
+}
+
 device_mapper_required_()
 {
   . "$abs_top_srcdir/tests/lvm-utils.sh" \



More information about the Parted-commits mailing list