coreutils
[Top][All Lists]
Advanced

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

Re: coreutils-8.12.193-d8dc8: 2 tests skipped: failed to create ext2 fil


From: Bernhard Voelker
Subject: Re: coreutils-8.12.193-d8dc8: 2 tests skipped: failed to create ext2 file system
Date: Wed, 07 Sep 2011 11:17:48 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110804 SUSE/3.1.12 Thunderbird/3.1.12

On 09/06/2011 10:58 PM, Jim Meyering wrote:
Bernhard Voelker wrote:
These 2 root checks fail because my USER doesn't have /sbin nor /usr/sbin in 
PATH.

I'd say they were skipped, not failed :-)

+1 for you ;-)

SKIP: cp/cp-mv-enotsup-xattr (exit: 77)
=======================================

+ dd if=/dev/zero of=noxattr.bin bs=8192 count=200
+ mkdir noxattr
+ mkfs -t ext2 -F noxattr.bin
./cp/cp-mv-enotsup-xattr: line 41: mkfs: command not found
+ skip_ 'failed to create ext2 file system'
+ warn_ 'cp-mv-enotsup-xattr: skipped test: failed to create ext2 file system'

SKIP: rm/read-only (exit: 77)
=============================
...
+ dd if=/dev/zero of=blob bs=8192 count=200
+ mkdir mnt
+ mkfs -t ext2 -F blob
./rm/read-only: line 31: mkfs: command not found
+ skip_ 'failed to create ext2 file system'
+ warn_ 'read-only: skipped test: failed to create ext2 file system'


If started with
   sudo env PATH="/sbin:$PATH" NON_ROOT_USERNAME=$USER make -k check-root
then they pass.

Should we
* add /sbin to PATH for the whole check-root test suite, or
* add it only for these 2 tests, or
* enhance the README file for this issue?

IMHO, having a usable PATH is a prerequisite.
If root's default search path lacks /sbin, you may want to
take that up with the folks who manage your distribution.
It's something that affects many packages, not just coreutils.

It's not root's PATH which lacks /sbin, but the PATH of a non-root user.
Running `sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root`
started as such non-root user will therefore also miss /sbin.


Saying something like that in README would be sort of like saying you must
have a user name.  While it is possible to do a lot of things with just
a numeric user ID, many tools require that you also have a corresponding
user name.  It's so basic that no one should have to bother to check or
warn about the possibility that the assumption does not hold.

Skipping a few tests is not a problem.

In spite of all that, I think that enough people would skip these tests
that it's worth addressing.  In case you're interested, here's the sort
of patch I'd like:

Add a function in tests/init.cfg named something like
require_mkfs_PATH_ that does this:

   if there is no mkfs in PATH
     if PATH does not contain /sbin
       if /sbin/mkfs is executable
         PATH=$PATH:/sbin

Then, invoke that new function from each of the two tests above
to make it less likely that they'll be skipped.


I had to add the new function to a few more tests which are skipped
on my system due to other reasons (e.g. missing selinux support).


From 3125dfbb76e2f1a31ad9318aa63ea500d250a4c1 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <address@hidden>
Date: Wed, 7 Sep 2011 11:05:49 +0200
Subject: [PATCH] tests: add mkfs to PATH for some check-root tests.

tests/init.cfg (require_mkfs_PATH_): New function to test whether mkfs
is in PATH, otherwise adding /sbin to PATH. Needed for distributions
(OpenSuSE, Solaris) which do not add /sbin to PATH for non-root users.
tests/cp/cp-a-selinux: Use require_mkfs_PATH_.
tests/cp/cp-mv-enotsup-xattr: Likewise.
tests/cp/sparse-fiemap: Likewise.
tests/mkdir/writeable-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                      |   18 ++++++++++++++++++
 tests/mkdir/writable-under-readonly |    1 +
 tests/rm/read-only                  |    1 +
 6 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/tests/cp/cp-a-selinux b/tests/cp/cp-a-selinux
index 8a8e374..0f9c149 100755
--- a/tests/cp/cp-a-selinux
+++ b/tests/cp/cp-a-selinux
@@ -23,6 +23,7 @@
 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 9857fec..32798d2 100755
--- a/tests/cp/cp-mv-enotsup-xattr
+++ b/tests/cp/cp-mv-enotsup-xattr
@@ -22,6 +22,7 @@
 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 5eedb4f..831bf0b 100755
--- a/tests/cp/sparse-fiemap
+++ b/tests/cp/sparse-fiemap
@@ -32,6 +32,7 @@ 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 b6ca86c..2677d83 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -180,6 +180,24 @@ uid_is_privileged_()
   esac
 }

+# Some distributions do not add /sbin to PATH for non-root users.
+# Test if mkfs is in PATH, otherwise try to adapt PATH.
+require_mkfs_PATH_()
+{
+  which mkfs >/dev/null 2>&1 \
+    && return
+
+  case ":$PATH:" in
+    *:/sbin:*) skip_ "no usable mkfs found" ;;
+  esac
+
+  [ -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 c0f83fb..3e42b1d 100755
--- a/tests/mkdir/writable-under-readonly
+++ b/tests/mkdir/writable-under-readonly
@@ -27,6 +27,7 @@
 . "${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 c52883b..489b1bf 100755
--- a/tests/rm/read-only
+++ b/tests/rm/read-only
@@ -19,6 +19,7 @@
 . "${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]