summaryrefslogtreecommitdiffstats
path: root/test/TEST-06-SELINUX
diff options
context:
space:
mode:
authorJohannes Segitz <jsegitz@suse.de>2023-08-17 19:04:53 +0200
committerGitHub <noreply@github.com>2023-08-17 19:04:53 +0200
commit5f22d16bb3c3bbb72c2847000e2e10bf1384c0f3 (patch)
tree012671beebbd390b21c33c642b224f843cfa8ef5 /test/TEST-06-SELINUX
parentMerge pull request #28832 from dtardon/list-clear (diff)
downloadsystemd-5f22d16bb3c3bbb72c2847000e2e10bf1384c0f3.tar.xz
systemd-5f22d16bb3c3bbb72c2847000e2e10bf1384c0f3.zip
test: Check that SELinux policy is available before running SELinux test (#28868)
* test: Check that SELinux policy is available before running SELinux test --------- Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>
Diffstat (limited to 'test/TEST-06-SELINUX')
-rwxr-xr-xtest/TEST-06-SELINUX/test.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh
index 340c74ef16..0757b38cc2 100755
--- a/test/TEST-06-SELINUX/test.sh
+++ b/test/TEST-06-SELINUX/test.sh
@@ -7,11 +7,16 @@ IMAGE_NAME="selinux"
TEST_NO_NSPAWN=1
# Requirements:
-# selinux-policy-targeted
+# A selinux policy is installed. Preferably selinux-policy-targeted, but it could work with others
# selinux-policy-devel
-# Check if selinux-policy-devel is installed, and if it isn't bail out early instead of failing
-test -f /usr/share/selinux/devel/include/system/systemd.if || exit 0
+# Check if
+# - selinux-policy-devel is installed and
+# - some selinux policy is installed. To keep this generic just check for the
+# existence of a directory below /etc/selinux/, indicating a SELinux policy is
+# installed
+# otherwise bail out early instead of failing
+test -f /usr/share/selinux/devel/include/system/systemd.if && find /etc/selinux -mindepth 1 -maxdepth 1 -not -empty -type d | grep -q . || exit 0
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"