tests: move "sparse-file" into test-lib.sh
authorJim Meyering <meyering@redhat.com>
Sat, 3 May 2008 13:46:41 +0000 (15:46 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 6 May 2008 06:21:30 +0000 (08:21 +0200)
* tests/sparse-file: Remove file  Move contents into ...
* tests/test-lib.sh (require_sparse_support_): ...here.  New function.
* tests/cp/sparse: Use the function, not the file.
* tests/du/8gb: Likewise.
* tests/Makefile.am (EXTRA_DIST): Remove sparse-file.

tests/Makefile.am
tests/cp/sparse
tests/du/8gb
tests/sparse-file [deleted file]
tests/test-lib.sh

index 62defa2..3674d3f 100644 (file)
@@ -19,7 +19,6 @@ EXTRA_DIST =          \
   require-perl         \
   sample-test          \
   setgid-check         \
-  sparse-file          \
   test-lib.sh
 
 ## N O T E :: Do not add more names to this list.
index dfb348d..0d915df 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $top_srcdir/tests/sparse-file
 . $top_srcdir/tests/test-lib.sh
+require_sparse_support_
 
 # Create a sparse file.
 # It has to be at least 128K in order to be sparse on some systems.
index b0a42c4..66f02e7 100755 (executable)
@@ -22,8 +22,8 @@ if test "$VERBOSE" = yes; then
   du --version
 fi
 
-. $top_srcdir/tests/sparse-file
 . $top_srcdir/tests/test-lib.sh
+require_sparse_support_
 
 dd bs=1 seek=8G of=big < /dev/null 2> /dev/null
 if test $? != 0; then
diff --git a/tests/sparse-file b/tests/sparse-file
deleted file mode 100644 (file)
index 4f98bfb..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# -*- sh -*-
-# Does the current (working-dir.) file system support sparse files?
-
-# Copyright (C) 2006, 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 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 whether we can create a sparse file.
-# For example, on Darwin6.5 with a file system of type hfs, it's not possible.
-# NTFS requires 128K before a hole appears in a sparse file.
-t=sparse.$$
-dd bs=1 seek=128K of=$t < /dev/null 2> /dev/null
-set x `du -sk $t`
-kb_size=$2
-rm -f $t
-if test $kb_size -ge 128; then
-  skip_test_ 'this file system does not support sparse files'
-fi
index bd6be42..5ff301c 100644 (file)
@@ -197,6 +197,23 @@ of group names or numbers.  E.g.,
   esac
 }
 
+# Does the current (working-dir) file system support sparse files?
+require_sparse_support_()
+{
+  test $# = 0 || framework_failure
+  # Test whether we can create a sparse file.
+  # For example, on Darwin6.5 with a file system of type hfs, it's not possible.
+  # NTFS requires 128K before a hole appears in a sparse file.
+  t=sparse.$$
+  dd bs=1 seek=128K of=$t < /dev/null 2> /dev/null
+  set x `du -sk $t`
+  kb_size=$2
+  rm -f $t
+  if test $kb_size -ge 128; then
+    skip_test_ 'this file system does not support sparse files'
+  fi
+}
+
 mkfifo_or_skip_()
 {
   test $# = 1 || framework_failure