From d6639ee63bc9321bc73ad453a266e45a89823a22 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 26 Aug 2009 10:06:53 +0200 Subject: [PATCH] tests: mkdir/selinux: avoid spurious failure on some SELinux systems * tests/test-lib.sh (require_selinux_enforcing_): New function. * tests/mkdir/selinux: Use it. Otherwise, this test would fail on Rawhide with SELinux disabled. --- tests/mkdir/selinux | 5 +++-- tests/test-lib.sh | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/mkdir/selinux b/tests/mkdir/selinux index b8ab404..ddd237c 100755 --- a/tests/mkdir/selinux +++ b/tests/mkdir/selinux @@ -23,11 +23,12 @@ if test "$VERBOSE" = yes; then mknod --version fi +. $srcdir/test-lib.sh + # Note: on an SELinux/enforcing system running mcstransd older than # mcstrans-0.2.8-1.fc9, the following commands may mistakenly exit # successfully, in spite of the invalid context string. - -. $srcdir/test-lib.sh +require_selinux_enforcing_ c=invalid-selinux-context msg="failed to set default file creation context to \`$c':" diff --git a/tests/test-lib.sh b/tests/test-lib.sh index ad7a0e9..4419742 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -47,6 +47,14 @@ require_acl_() || skip_test_ "This test requires a local user named bin." } +# Skip this test if we're not in SELinux "enforcing" mode. +require_selinux_enforcing_() +{ + test "$(getenforce)" = Enforcing \ + || skip_test_ "This test is useful only with SELinux in Enforcing mode." +} + + require_openat_support_() { # Skip this test if your system has neither the openat-style functions -- 2.7.4