From 2656da4705eb26a30da6b51be18d9ba474bc4d00 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 3 May 2008 15:46:41 +0200 Subject: tests: move "sparse-file" into test-lib.sh * 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 | 1 - tests/cp/sparse | 2 +- tests/du/8gb | 2 +- tests/sparse-file | 29 ----------------------------- tests/test-lib.sh | 17 +++++++++++++++++ 5 files changed, 19 insertions(+), 32 deletions(-) delete mode 100644 tests/sparse-file (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 62defa25a..3674d3f32 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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. diff --git a/tests/cp/sparse b/tests/cp/sparse index dfb348db3..0d915df57 100755 --- a/tests/cp/sparse +++ b/tests/cp/sparse @@ -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. diff --git a/tests/du/8gb b/tests/du/8gb index b0a42c4ad..66f02e78b 100755 --- a/tests/du/8gb +++ b/tests/du/8gb @@ -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 index 4f98bfb87..000000000 --- a/tests/sparse-file +++ /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 . - -# 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 diff --git a/tests/test-lib.sh b/tests/test-lib.sh index bd6be422b..5ff301c6f 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -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 -- cgit v1.2.3-54-g00ecf