On 02/09/10 12:39, Jim Meyering wrote:
> Regarding your proposed new test, there is a slightly
> more efficient way to do it:
> 
>   $ git grep df.--local tests
>   tests/du/basic:if df --local . >/dev/null 2>&1; then
>   tests/du/slink:if df --local . >/dev/null 2>&1; then
>   ...
> 
> I.e., you can examine merely the exit status.
> If you do that, please encapsulate the test in a function
> to be defined in tests/init.cfg, I suppose.

OK cool,
I'll apply something like the following untested patch later.

cheers,
Pádraig.
commit 70ea591912901d58034af5073be1b7bb00e312fe
Author: Pádraig Brady <[email protected]>
Date:   Thu Sep 2 13:22:41 2010 +0100

    tests: exclude some tests when running on NFS
    
    * tests/init.cfg (is_local_dir_): A new function
    returning if the current directory is on a local file system.
    (require_local_dir_): A new function to skip tests
    if not on a local dir.
    * tests/cp/existing-perm-race: Skip if non local.
    * tests/cp/file-perm-race: Likewise.
    * tests/cp/parent-perm: Likewise.
    * tests/cp/parent-perm-race: Likewise.
    * tests/cp/preserve-2: Likewise.
    * tests/mv/part-symlink: Likewise.
    * tests/du/basic: Use refactored function.
    * tests/du/slink: Likewise.

diff --git a/tests/cp/existing-perm-race b/tests/cp/existing-perm-race
index b6168f6..f1487ef 100755
--- a/tests/cp/existing-perm-race
+++ b/tests/cp/existing-perm-race
@@ -22,7 +22,9 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/test-lib.sh
+
 require_membership_in_two_groups_
+require_local_dir_
 
 set _ $groups; shift
 g1=$1
diff --git a/tests/cp/file-perm-race b/tests/cp/file-perm-race
index ca47169..606c313 100755
--- a/tests/cp/file-perm-race
+++ b/tests/cp/file-perm-race
@@ -23,6 +23,8 @@ fi
 
 . $srcdir/test-lib.sh
 
+require_local_dir_
+
 umask 022
 mkfifo fifo ||
   skip_test_ "fifos not supported"
diff --git a/tests/cp/parent-perm b/tests/cp/parent-perm
index 4912694..d0eb706 100755
--- a/tests/cp/parent-perm
+++ b/tests/cp/parent-perm
@@ -24,6 +24,7 @@ fi
 . $srcdir/test-lib.sh
 
 working_umask_or_skip_
+require_local_dir_
 
 mkdir -p a/b/c a/b/d e || framework_failure
 touch a/b/c/foo a/b/d/foo || framework_failure
diff --git a/tests/cp/parent-perm-race b/tests/cp/parent-perm-race
index 5461238..3151000 100755
--- a/tests/cp/parent-perm-race
+++ b/tests/cp/parent-perm-race
@@ -23,6 +23,8 @@ fi
 
 . $srcdir/test-lib.sh
 
+require_local_dir_
+
 umask 002
 mkdir mode ownership d || framework_failure
 chmod g+s d 2>/dev/null # The cp test is valid either way.
diff --git a/tests/cp/preserve-2 b/tests/cp/preserve-2
index f65b420..bdf69e1 100755
--- a/tests/cp/preserve-2
+++ b/tests/cp/preserve-2
@@ -23,8 +23,9 @@ fi
 
 . $srcdir/test-lib.sh
 
-touch f || framework_failure
+require_local_dir_
 
+touch f || framework_failure
 
 cp --preserve=mode,links f g || fail=1
 
diff --git a/tests/du/basic b/tests/du/basic
index 8b72853..02deb1d 100755
--- a/tests/du/basic
+++ b/tests/du/basic
@@ -63,7 +63,7 @@ compare out exp || fail=1
 
 # Perform this test only if "." is on a local file system.
 # Otherwise, it would fail e.g., on an NFS-mounted Solaris ZFS file system.
-if df --local . >/dev/null 2>&1; then
+if is_local_dir_; then
   rm -f out exp
   du --block-size=$B -a d | sort -r -k2,2 > out || fail=1
   echo === >> out
diff --git a/tests/du/slink b/tests/du/slink
index 2bb3757..fade72c 100755
--- a/tests/du/slink
+++ b/tests/du/slink
@@ -25,13 +25,7 @@ fi
 
 # Determine if `.' is on a local (would non-NFS be sufficient?) file system.
 # On at least some NFS implementations, symlinks never take up space,
-
-# So if this is a non-local file system, skip the test.
-if df --local . >/dev/null 2>&1; then
-  : # Ok.
-else
-  skip_test_ "\`.' is on a non-local file system"
-fi
+require_local_dir_
 
 if df --type=xfs . >/dev/null 2>&1; then
   # At least on Irix-6.5.19, when using an xfs file system,
diff --git a/tests/init.cfg b/tests/init.cfg
index 232cb9b..ab18eb1 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -56,6 +56,17 @@ require_acl_()
     || skip_test_ "This test requires a local user named bin."
 }
 
+is_local_dir_()
+{
+  df --local . >/dev/null 2>&1
+}
+
+require_local_dir_()
+{
+  is_local_dir ||
+    skip_test_ "This test requires a local file system."
+}
+
 # Skip this test if we're not in SELinux "enforcing" mode.
 require_selinux_enforcing_()
 {
diff --git a/tests/mv/part-symlink b/tests/mv/part-symlink
index 00c706b..b97fe04 100755
--- a/tests/mv/part-symlink
+++ b/tests/mv/part-symlink
@@ -27,6 +27,8 @@ fi
 cleanup_() { rm -rf "$other_partition_tmpdir"; }
 . "$abs_srcdir/other-fs-tmpdir"
 
+require_local_dir_
+
 pwd_tmp=`pwd`
 
 # Unset CDPATH.  Otherwise, output from the `cd dir' command

Reply via email to