]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: Factor out code that's going to be reused.
authorPádraig Brady <P@draigBrady.com>
Fri, 28 Mar 2008 13:32:44 +0000 (14:32 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 28 Mar 2008 13:33:27 +0000 (14:33 +0100)
* tests/test-lib.sh (mkfifo_or_skip_): New function, factored out of...
* tests/touch/fifo: ...here.

tests/test-lib.sh
tests/touch/fifo

index c494e19ff87a2f41daf4cdfe798ba1ee579c4cd9..078afca4dde9e6af32e30f0e093a7273e775577e 100644 (file)
@@ -120,6 +120,18 @@ skip_if_root_() { uid_is_privileged_ && skip_test_ "must be run as non-root"; }
 error_() { echo "$0: $@" 1>&2; (exit 1); exit 1; }
 framework_failure() { error_ 'failure in testing framework'; }
 
+mkfifo_or_skip_()
+{
+  test $# = 1 || framework_failure
+  if ! mkfifo "$1"; then
+    # Make an exception of this case -- usually we interpret framework-creation
+    # failure as a test failure.  However, in this case, when running on a SunOS
+    # system using a disk NFS mounted from OpenBSD, the above fails like this:
+    # mkfifo: cannot make fifo `fifo-10558': Not owner
+    skip_test_ 'NOTICE: unable to create test prerequisites'
+  fi
+}
+
 test_dir_=$(pwd)
 
 this_test_() { echo "./$0" | sed 's,.*/,,'; }
index 00b46f5c584ac628435416fda2f9021274a9b543..5dd0840657df016e8c5f1eb01ec941d005b166ed 100755 (executable)
@@ -23,13 +23,7 @@ fi
 
 . $srcdir/../test-lib.sh
 
-if ! mkfifo fifo; then
-  # Make an exception of this case -- usually we interpret framework-creation
-  # failure as a test failure.  However, in this case, when running on a SunOS
-  # system using a disk NFS mounted from OpenBSD, the above fails like this:
-  # mkfifo: cannot make fifo `fifo-10558': Not owner
-  skip_test_ 'NOTICE: unable to create test prerequisites'
-fi
+mkfifo_or_skip_ fifo
 
 fail=0