coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: adjust PATH to generally include /sbin and /usr/sbin


From: Bernhard Voelker
Subject: [PATCH] tests: adjust PATH to generally include /sbin and /usr/sbin
Date: Thu, 01 Dec 2011 01:17:58 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111101 SUSE/3.1.16 Thunderbird/3.1.16

As a replacement for my previously proposed patch:
"[PATCH] tests: adjust PATH to include /usr/sbin for filefrag-using tests"
(see http://lists.gnu.org/archive/html/coreutils/2011-11/msg00086.html),
and after some confusion in the discussion, the following patch adds
/sbin and /usr/sbin generally for all tests.

Have a nice day,
Berny

>From 18cf7bfcb8de38fa6280bfa68e8e02f30f91ec2a Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <address@hidden>
Date: Thu, 1 Dec 2011 01:04:34 +0100
Subject: [PATCH] tests: adjust PATH to generally include /sbin and /usr/sbin

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               |    1 -
 tests/cp/cp-mv-enotsup-xattr        |    1 -
 tests/cp/sparse-fiemap              |    1 -
 tests/init.cfg                      |   25 ++++++++-----------------
 tests/mkdir/writable-under-readonly |    1 -
 tests/rm/read-only                  |    1 -
 6 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/tests/cp/cp-a-selinux b/tests/cp/cp-a-selinux
index 7ef24d8..fd0ddab 100755
--- a/tests/cp/cp-a-selinux
+++ b/tests/cp/cp-a-selinux
@@ -23,7 +23,6 @@
 print_ver_ cp
 require_root_
 require_selinux_
-require_mkfs_PATH_

 cwd=`pwd`
 cleanup_() { cd /; umount "$cwd/mnt"; }
diff --git a/tests/cp/cp-mv-enotsup-xattr b/tests/cp/cp-mv-enotsup-xattr
index f303581..17ac6a4 100755
--- a/tests/cp/cp-mv-enotsup-xattr
+++ b/tests/cp/cp-mv-enotsup-xattr
@@ -22,7 +22,6 @@
 print_ver_ cp mv

 require_root_
-require_mkfs_PATH_

 cwd=`pwd`
 cleanup_() { cd /; umount "$cwd/noxattr"; umount "$cwd/xattr"; }
diff --git a/tests/cp/sparse-fiemap b/tests/cp/sparse-fiemap
index 831bf0b..5eedb4f 100755
--- a/tests/cp/sparse-fiemap
+++ b/tests/cp/sparse-fiemap
@@ -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"; }
diff --git a/tests/init.cfg b/tests/init.cfg
index 9b05b34..216991f 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -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.
+# Additionally assure that /sbin and /usr/sbin are included in PATH.
 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
diff --git a/tests/mkdir/writable-under-readonly 
b/tests/mkdir/writable-under-readonly
index 3e42b1d..c0f83fb 100755
--- a/tests/mkdir/writable-under-readonly
+++ b/tests/mkdir/writable-under-readonly
@@ -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
diff --git a/tests/rm/read-only b/tests/rm/read-only
index 489b1bf..c52883b 100755
--- a/tests/rm/read-only
+++ b/tests/rm/read-only
@@ -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"; }
-- 
1.7.3.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]