public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: skip the policy which is not installed
@ 2026-09-11 13:19 Milos Malik
  0 siblings, 0 replies; only message in thread
From: Milos Malik @ 2026-09-11 13:19 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 28aaa75dde48779df78ffec408732e0f215c7339
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2021-05-14T10:00:47+02:00
            Stats  : +10/-6 in 2 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/28aaa75dde48779df78ffec408732e0f215c7339?branch=pr775-checkpolicy-revdeps

            Log:
            skip the policy which is not installed

The TC expected that all SELinux policies are installed before the
TC is executed. If some of them is not installed, one of the test
phases failed.
Now, the test phase checks if particular policy is installed before
calling the D-bus interface on it.

---
diff --git a/policycoreutils/org-selinux-dbus-interfaces/Makefile b/policycoreutils/org-selinux-dbus-interfaces/Makefile
index 92c8af6..6756710 100644
--- a/policycoreutils/org-selinux-dbus-interfaces/Makefile
+++ b/policycoreutils/org-selinux-dbus-interfaces/Makefile
@@ -63,3 +63,4 @@ $(METADATA): Makefile
 	@echo "Bug:             1754873" >> $(METADATA) # RHEL-8
 
 	rhts-lint $(METADATA)
+

diff --git a/policycoreutils/org-selinux-dbus-interfaces/runtest.sh b/policycoreutils/org-selinux-dbus-interfaces/runtest.sh
index 458c695..14779a5 100755
--- a/policycoreutils/org-selinux-dbus-interfaces/runtest.sh
+++ b/policycoreutils/org-selinux-dbus-interfaces/runtest.sh
@@ -91,13 +91,16 @@ rlJournalStart
     rlPhaseEnd
 
     rlPhaseStartTest "org.selinux.change_default_policy"
+        # 1 argument is missing
         rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy" 1
-        rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:minimum"
-        rlRun "grep SELINUXTYPE=minimum /etc/selinux/config"
-        rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:mls"
-        rlRun "grep SELINUXTYPE=mls /etc/selinux/config"
-        rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:targeted"
-        rlRun "grep SELINUXTYPE=targeted /etc/selinux/config"
+        # test existing policies
+        for POLICY_KIND in minimum mls targeted ; do
+            if rpm -q selinux-policy-${POLICY_KIND} ; then
+                rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:${POLICY_KIND}"
+                rlRun "grep SELINUXTYPE=${POLICY_KIND} /etc/selinux/config"
+            fi
+        done
+        # test a non-existent policy
         rlRun "dbus-send --system --print-reply --dest=org.selinux /org/selinux/object org.selinux.change_default_policy string:xyz" 1
     rlPhaseEnd
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-11 13:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 13:19 [tests/selinux] pr775-checkpolicy-revdeps: skip the policy which is not installed Milos Malik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox