public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] pr775-checkpolicy-revdeps: add a simplified version of rlSESatisfyRequires()
@ 2026-09-11 13:20 Milos Malik
  0 siblings, 0 replies; only message in thread
From: Milos Malik @ 2026-09-11 13:20 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : d1caaec9e27d67cb82ba0810567300509df716e1
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2022-11-22T14:14:16+01:00
            Stats  : +31/-1 in 2 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/d1caaec9e27d67cb82ba0810567300509df716e1?branch=pr775-checkpolicy-revdeps

            Log:
            add a simplified version of rlSESatisfyRequires()

If the framework which runs the automated tests does not install
all required packages (listed in Makefile) before the tests are
started, then rlSESatisfyRequires() installs the required packages
during the run of the tests.

---
diff --git a/selinux-policy/Library/common/lib.sh b/selinux-policy/Library/common/lib.sh
index 22a7b31..4bcb8ee 100644
--- a/selinux-policy/Library/common/lib.sh
+++ b/selinux-policy/Library/common/lib.sh
@@ -1524,9 +1524,39 @@ function rlSESetEnforce() {
 
 }
 
+true <<'=cut'
+=pod
+
+=head2 rlSESatisfyRequires
+
+The function attempts to install all packages required in Makefile and all packa
+ges given as arguments.
+The function will be used to install packages from any repository we want.
+
+=cut
 
+function rlSESatisfyRequires() {
+    local FILE_NAME="./Makefile"
+    local PACKAGE_LIST
+    local PACKAGE_LIST2
 
+    if [ "x$COLLECTIONS" != "x" ] ; then
+        # do not install any packages when running in RHSCL environment
+        # because that would most likely break the environment or fail
+        return
+    fi
+    if [ $# -gt 0 ] ; then
+        PACKAGE_LIST2="$*"
+    fi
+    PACKAGE_LIST=`grep '"Requires:' ${FILE_NAME} | cut -d : -f 2 | cut -d '"' -f 1 | tr '\n' ' ' | tr -s ' '`
+    # check if all required packages are really installed
+    if rpm -q ${PACKAGE_LIST} ${PACKAGE_LIST2} >& /dev/null ; then
+        rlPass "all required packages are really installed"
+        return 0
+    fi
 
+    rlRun "epelyum -y --nobest --nogpgcheck --skip-broken install ${PACKAGE_LIST} ${PACKAGE_LIST2}" 0,1
+}
 
 __INTERNAL_rlSEModuleList() {
   local semodule_list

diff --git a/selinux-policy/cups-lpd-and-similar/runtest.sh b/selinux-policy/cups-lpd-and-similar/runtest.sh
index 3d30478..1ada2fc 100755
--- a/selinux-policy/cups-lpd-and-similar/runtest.sh
+++ b/selinux-policy/cups-lpd-and-similar/runtest.sh
@@ -41,7 +41,7 @@ PROCESS_CONTEXT="cupsd_lpd_t"
 rlJournalStart
     rlPhaseStartSetup
         rlRun "rlImport 'selinux-policy/common'"
-        # rlSESatisfyRequires
+        rlSESatisfyRequires
         rlAssertRpm ${PACKAGE}
         rlAssertRpm ${PACKAGE}-targeted
         rlAssertRpm ${SERVICE_PACKAGE}

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

only message in thread, other threads:[~2026-09-11 13:20 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:20 [tests/selinux] pr775-checkpolicy-revdeps: add a simplified version of rlSESatisfyRequires() Milos Malik

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