[parted-devel] [PATCH] Avoid unnecessary writes in test scripts.

Jim Meyering jim at meyering.net
Mon Jun 11 11:12:10 UTC 2007


This changes the tests to create sparse files for some test inputs
rather than zero-filled non-sparse ones.  Doing this cuts more than 50% off
the run time of "make check" in the tests/ directory.

Signed-off-by: Jim Meyering <jim at meyering.net>
---
 tests/t0000-basic.sh       |    4 ++--
 tests/t1000-mkpartfs.sh    |    4 ++--
 tests/t1500-small-ext2.sh  |    2 +-
 tests/t2000-mkfs.sh        |    6 +++---
 tests/t3000-constraints.sh |    2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/t0000-basic.sh b/tests/t0000-basic.sh
index 1a11121..83abcea 100755
--- a/tests/t0000-basic.sh
+++ b/tests/t0000-basic.sh
@@ -37,7 +37,7 @@ dev=loop-file
 
 test_expect_success \
     'create the test file' \
-    'dd if=/dev/zero of=$dev bs=$N count=1 2> /dev/null'
+    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
 
 test_expect_success \
     'run parted -s FILE mklabel msdos' \
@@ -50,7 +50,7 @@ test_expect_success 'expect no output' '$compare out /dev/null'
 
 test_expect_success \
     'erase the left-over label' \
-    'dd if=/dev/zero of=$dev bs=$N count=1 2> /dev/null'
+    'dd if=/dev/zero of=$dev bs=1K count=1 2> /dev/null'
 
 # First iteration works with no prompting, since there is no preexisting label.
 test_expect_success \
diff --git a/tests/t1000-mkpartfs.sh b/tests/t1000-mkpartfs.sh
index 30f7238..b185034 100755
--- a/tests/t1000-mkpartfs.sh
+++ b/tests/t1000-mkpartfs.sh
@@ -25,7 +25,7 @@ N=1M
 dev=loop-file
 test_expect_success \
     'create a file too small to hold a fat32 file system' \
-    'dd if=/dev/zero of=$dev bs=$N count=1 2> /dev/null'
+    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
 
 test_expect_success \
     'label the test disk' \
@@ -53,7 +53,7 @@ N=40M
 
 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'
+    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
 
 test_expect_success \
     'label the test disk' \
diff --git a/tests/t1500-small-ext2.sh b/tests/t1500-small-ext2.sh
index 887a5f5..e53b985 100755
--- a/tests/t1500-small-ext2.sh
+++ b/tests/t1500-small-ext2.sh
@@ -24,7 +24,7 @@ test_description='Create very small ext2 file systems.'
 dev=loop-file
 test_expect_success \
     'setup' '
-    dd if=/dev/zero of=$dev bs=10M count=1 2> /dev/null &&
+    dd if=/dev/null of=$dev bs=1 seek=10M 2> /dev/null &&
     parted -s $dev mklabel msdos'
 
 test_expect_failure \
diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh
index e1a01fc..6178c52 100755
--- a/tests/t2000-mkfs.sh
+++ b/tests/t2000-mkfs.sh
@@ -25,7 +25,7 @@ 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'
+    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
 
 test_expect_success \
     'label the test disk' \
@@ -45,7 +45,7 @@ test_expect_success 'expect no output' '$compare out /dev/null'
 N=10M
 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'
+    'dd if=/dev/null of=$dev bs=1 seek=$N 2> /dev/null'
 
 test_expect_success \
     'label the test disk' \
@@ -88,7 +88,7 @@ dev=loop-file
 
 test_expect_success \
     "setup: create and label a device" \
-    'dd if=/dev/zero of=$dev bs=1M count=1 2>/dev/null &&
+    'dd if=/dev/null of=$dev bs=1 seek=1M 2>/dev/null &&
      parted -s $dev mklabel msdos'
 
 test_expect_failure \
diff --git a/tests/t3000-constraints.sh b/tests/t3000-constraints.sh
index 179a33c..f06e9f5 100755
--- a/tests/t3000-constraints.sh
+++ b/tests/t3000-constraints.sh
@@ -27,7 +27,7 @@ t=ext2
 
 test_expect_success \
     "setup: label and create a small $t partition" \
-    'dd if=/dev/zero of=$dev bs=${N}M count=1 2>/dev/null &&
+    'dd if=/dev/null of=$dev bs=1 seek=${N}M 2>/dev/null &&
      { echo y; echo c; } > in &&
      { emit_superuser_warning
        echo "Warning: You requested a partition from 1000kB to 2000kB."



More information about the parted-devel mailing list