]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: skip another test if mcstransd is running
authorJim Meyering <meyering@redhat.com>
Mon, 5 May 2008 13:17:42 +0000 (15:17 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 6 May 2008 06:21:30 +0000 (08:21 +0200)
* tests/test-lib.sh (skip_if_mcstransd_is_running_): New function,
extracted from...
* tests/misc/chcon: ...here.  Use function, not open-coded test.
* tests/misc/selinux: Use the function here, too.
Require root, not non-root.
* tests/Makefile.am (root_tests): Add misc/selinux.

tests/Makefile.am
tests/misc/chcon
tests/misc/selinux
tests/test-lib.sh

index c22b62edf1f8744a3abf34ba659cb7de194990a2..daf2e5a9f81aff36130224c6f8e00d6e57a830ac 100644 (file)
@@ -32,6 +32,7 @@ root_tests =                                  \
   cp/special-bits                              \
   ls/nameless-uid                              \
   misc/chcon                                   \
+  misc/selinux                                 \
   mkdir/writable-under-readonly                        \
   mv/sticky-to-xpart                           \
   rm/fail-2eperm                               \
index e637893ef3f738a6e330ef791af3bf910ae0f913..d7a9c5f31f01b635063a94a41065996b3b08e039 100755 (executable)
@@ -9,16 +9,7 @@ fi
 . $top_srcdir/tests/test-lib.sh
 require_root_
 require_selinux_
-
-# When mcstransd is running, you'll see only the 3-component
-# version of file-system context strings.  Detect that,
-# and if it's running, skip this test.
-ctx=$(stat --printf='%C\n' .) || framework_failure
-case $ctx in
-  *:*:*:*) ;; # four components is ok
-  *) # anything else probably means mcstransd is running
-      skip_test_ "unexpected context '$ctx'; turn off mcstransd" ;;
-esac
+skip_if_mcstransd_is_running_
 
 mkdir -p d/sub/s2 || framework_failure
 touch f g d/sub/1 d/sub/2 || framework_failure
index e946664924270f4786a456c9aa30897f117ea48b..87b3af250cc1becb12adc00bb50c9cc438792103 100755 (executable)
@@ -11,8 +11,9 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $top_srcdir/tests/test-lib.sh
-skip_if_root_
+require_root_
 require_selinux_
+skip_if_mcstransd_is_running_
 
 # Create a regular file, dir, fifo.
 touch f || framework_failure
@@ -21,10 +22,10 @@ mkfifo p || framework_failure
 
 fail=0
 
-ctx=root:object_r:tmp_t
-# FIXME, what if $ctx is no different from the default.  Not likely.
-# give each a different context, via chcon
-chcon $ctx f d p 2>/dev/null ||
+# special context that works both with and without mcstransd
+ctx=root:object_r:tmp_t:s0
+
+chcon $ctx f d p ||
   skip_test_ '"chcon '$ctx' ..." failed'
 
 # inspect that context with both ls -Z and stat.
index 5ff301c6f1d937c3105c8a58012378f56f643be1..2083d0c15b03db8cc63193696c673d31df63ae8f 100644 (file)
@@ -226,6 +226,21 @@ mkfifo_or_skip_()
   fi
 }
 
+skip_if_mcstransd_is_running_()
+{
+  test $# = 0 || framework_failure
+
+  # When mcstransd is running, you'll see only the 3-component
+  # version of file-system context strings.  Detect that,
+  # and if it's running, skip this test.
+  local ctx=$(stat --printf='%C\n' .) || framework_failure
+  case $ctx in
+    *:*:*:*) ;; # four components is ok
+    *) # anything else probably means mcstransd is running
+        skip_test_ "unexpected context '$ctx'; turn off mcstransd" ;;
+  esac
+}
+
 # Skip the current test if umask doesn't work as usual.
 # This test should be run in the temporary directory that ends
 # up being removed via the trap commands.