diff options
author | Pádraig Brady <P@draigBrady.com> | 2013-12-05 00:02:41 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2013-12-05 00:27:11 +0000 |
commit | 37e001d20930bacf188ab9725d063e205b195e34 (patch) | |
tree | 8d78991eaa48e59e407bafd3ef3b966f3259000f | |
parent | 0013de3e603162081c4464ea1f7ad3285f633d78 (diff) | |
download | coreutils-37e001d20930bacf188ab9725d063e205b195e34.tar.xz |
tests: fix false failure with disabled SELinux support
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.
-rw-r--r-- | init.cfg | 42 |
1 files changed, 24 insertions, 18 deletions
@@ -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 |