]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: adjust PATH to generally include /sbin and /usr/sbin
authorBernhard Voelker <mail@bernhard-voelker.de>
Thu, 1 Dec 2011 00:04:34 +0000 (01:04 +0100)
committerJim Meyering <meyering@redhat.com>
Thu, 1 Dec 2011 08:07:13 +0000 (09:07 +0100)
Commit 5eeaca94 added /sbin to the PATH for tests using mkfs. For other
tests, e.g. tests/cp-fiemap-perf using filefrag, we need /usr/sbin also.
Add both directories generally for the tests, "since many of us always
augment our PATH with all of the sbin paths all of the time anyway" (Bob
in http://lists.gnu.org/archive/html/coreutils/2011-11/msg00107.html).
The previous commit is hereby obsolete.
* tests/init.cfg (sanitize_path_): Add /sbin and /usr/sbin to PATH
unless already included. Needed for tests using admin tools like mkfs
and filefrag on systems where the user's environment does not have
these directories in the PATH.
* tests/init.cfg (require_mkfs_PATH_): Remove obsolete function.
* tests/cp/cp-a-selinux: Remove require_mkfs_PATH_ call.
* tests/cp/cp-mv-enotsup-xattr: Likewise.
* tests/cp/sparse-fiemap: Likewise.
* tests/mkdir/writable-under-readonly: Likewise.
* tests/rm/read-only: Likewise.

tests/cp/cp-a-selinux
tests/cp/cp-mv-enotsup-xattr
tests/cp/sparse-fiemap
tests/init.cfg
tests/mkdir/writable-under-readonly
tests/rm/read-only

index 7ef24d801c4ed92925c2d3faeee0677be3b5d8ce..fd0ddaba05950d931ee246aa5bfcd6c4239f7f7c 100755 (executable)
@@ -23,7 +23,6 @@
 print_ver_ cp
 require_root_
 require_selinux_
-require_mkfs_PATH_
 
 cwd=`pwd`
 cleanup_() { cd /; umount "$cwd/mnt"; }
index f30358136da3ce470ada12c0f2601551ba760cd0..17ac6a4b44d3d381b0a06d580ac6fe9860842b35 100755 (executable)
@@ -22,7 +22,6 @@
 print_ver_ cp mv
 
 require_root_
-require_mkfs_PATH_
 
 cwd=`pwd`
 cleanup_() { cd /; umount "$cwd/noxattr"; umount "$cwd/xattr"; }
index 831bf0bdd4bf43a0a229099946e8a17429236ced..5eedb4fa7207b6713ef2158495d6419642de92ea 100755 (executable)
@@ -32,7 +32,6 @@ else
 
   # It's not;  we need to create one, hence we need root access.
   require_root_
-  require_mkfs_PATH_
 
   cwd=$PWD
   cleanup_() { cd /; umount "$cwd/mnt"; }
index 9b05b341892568c6908d74c817fdb849a9ee5f94..938d1bbab4536a52c81207c6f2d191fb4f6b81e2 100644 (file)
@@ -23,6 +23,7 @@ stderr_fileno_=9
 # Having an unsearchable directory in PATH causes execve to fail with EACCES
 # when applied to an unresolvable program name, contrary to the desired ENOENT.
 # Avoid the problem by rewriting PATH to exclude unsearchable directories.
+# Also, if PATH lacks /sbin and/or /usr/sbin, append it/them.
 sanitize_path_()
 {
   # FIXME: remove double quotes around $IFS when all tests use init.sh.
@@ -43,6 +44,13 @@ sanitize_path_()
     fi
   done
 
+  for d in /sbin /usr/sbin ; do
+    case ":$new_path:" in
+      *:$d:*) ;;
+      *) new_path="$new_path:$d" ;;
+    esac
+  done
+
   PATH=$new_path
   export PATH
 }
@@ -195,23 +203,6 @@ uid_is_privileged_()
   esac
 }
 
-# Some versions of sudo do not include /sbin in PATH.
-# Test if mkfs is in PATH, otherwise try to adapt PATH.
-require_mkfs_PATH_()
-{
-  type mkfs && return
-
-  case ":$PATH:" in
-    *:/sbin:*) skip_ "no usable mkfs found" ;;
-  esac
-
-  test -x /sbin/mkfs \
-    || skip_ "no usable mkfs found"
-
-  PATH="$PATH:/sbin"
-  export PATH
-}
-
 get_process_status_()
 {
   sed -n '/^State:[     ]*\([[:alpha:]]\).*/s//\1/p' /proc/$1/status
index 3e42b1d787f6125cfa6182f875af89447aa2a3e8..c0f83fb5b2a6b078b15cd52be5d87924eac4d2a5 100755 (executable)
@@ -27,7 +27,6 @@
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ mkdir
 require_root_
-require_mkfs_PATH_
 
 # FIXME: for now, skip it unconditionally
 skip_ temporarily disabled
index 489b1bf3db5a8ca518293cc17b9b43f78106ba63..c52883b60b4c0fc4776d4e708d4a4ff5733f7ad8 100755 (executable)
@@ -19,7 +19,6 @@
 . "${srcdir=.}/init.sh"; path_prepend_ ../src
 print_ver_ rm
 require_root_
-require_mkfs_PATH_
 
 cwd=`pwd`
 cleanup_() { cd /; umount "$cwd/mnt"; }