]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: fix false failure with disabled SELinux support
authorPádraig Brady <P@draigBrady.com>
Thu, 5 Dec 2013 00:02:41 +0000 (00:02 +0000)
committerPádraig Brady <P@draigBrady.com>
Thu, 5 Dec 2013 00:27:11 +0000 (00:27 +0000)
This could trigger on SELinux systems where we build --qithout-selinux
or where the SELinux development libraries are not installed.

* init.cfg (require_selinux_enforcing_): Call require_selinux_()
to determine if the current build supports SELinux.  This avoids
a false failure in tests/mkdir/selinux.sh where only mkdir would
determine that SELinux was disabled and thus ignore invalid contexts.
(require_selinux_): Refactor a little to distinguish whether it's
the build or the (file) system that doesn't support SELinux.

init.cfg

index c48607c93560aa8715e2e37ee5e9a164f8ff4203..360d4da2bde0e1672868f7a5ed203b759b7149d4 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -90,9 +90,31 @@ require_local_dir_()
     skip_ "This test must be run on a local file system."
 }
 
+require_selinux_()
+{
+  # When in a chroot of an SELinux-enabled system, but with a mock-simulated
+  # SELinux-*disabled* system, recognize that SELinux is disabled system wide:
+  grep 'selinuxfs$' /proc/filesystems > /dev/null \
+    || skip_ "this system lacks SELinux support"
+
+  # Independent of whether SELinux is enabled system-wide,
+  # the current file system may lack SELinux support.
+  # Also the current build may have SELinux support disabled.
+  case $(ls -Zd .) in
+    '? .'|'unlabeled .')
+      test -z "$CONFIG_HEADER" \
+        && framework_failure_ 'CONFIG_HEADER not defined'
+      grep '^#define HAVE_SELINUX_SELINUX_H 1' "$CONFIG_HEADER" > /dev/null \
+        && selinux_missing_="(file) system" || selinux_missing_="build"
+      skip_ "this $selinux_missing_ lacks SELinux support"
+    ;;
+  esac
+}
+
 # Skip this test if we're not in SELinux "enforcing" mode.
 require_selinux_enforcing_()
 {
+  require_selinux_
   test "$(getenforce)" = Enforcing \
     || skip_ "This test is useful only with SELinux in Enforcing mode."
 }
@@ -101,8 +123,9 @@ require_openat_support_()
 {
   # Skip this test if your system has neither the openat-style functions
   # nor /proc/self/fd support with which to emulate them.
+
   test -z "$CONFIG_HEADER" \
-    && skip_ 'internal error: CONFIG_HEADER not defined'
+    && framework_failure_ 'CONFIG_HEADER not defined'
 
   _skip=yes
   grep '^#define HAVE_OPENAT' "$CONFIG_HEADER" > /dev/null && _skip=no
@@ -299,23 +322,6 @@ skip_if_()
   esac
 }
 
-require_selinux_()
-{
-  # When in a chroot of an SELinux-enabled system, but with a mock-simulated
-  # SELinux-*disabled* system, recognize that SELinux is disabled system wide:
-  grep 'selinuxfs$' /proc/filesystems > /dev/null \
-    || skip_ "this system lacks SELinux support"
-
-  # Independent of whether SELinux is enabled system-wide,
-  # the current file system may lack SELinux support.
-  case $(ls -Zd .) in
-    '? .'|'unlabeled .')
-      skip_ "this system (or maybe just" \
-        "the current file system) lacks SELinux support"
-    ;;
-  esac
-}
-
 very_expensive_()
 {
   if test "$RUN_VERY_EXPENSIVE_TESTS" != yes; then