public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: libselinux/python-bindings: Basic selinux python module checks
Date: Fri, 11 Sep 2026 13:17:32 GMT	[thread overview]
Message-ID: <178913265259.1.1607613946897184129.tests-selinux-2e7483099e85@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : 2e7483099e85867d2a9cb154e6d4aafd3b53680e
            Author : Petr Lautrbach <plautrba@redhat.com>
            Date   : 2019-06-25T15:11:17+02:00
            Stats  : +137/-0 in 4 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/2e7483099e85867d2a9cb154e6d4aafd3b53680e?branch=pr775-checkpolicy-revdeps

            Log:
            libselinux/python-bindings: Basic selinux python module checks

- compare rpm and python metadata version
- import selinux module and try selinux.is_selinux_enabled()

---
diff --git a/libselinux/python-bindings/Makefile b/libselinux/python-bindings/Makefile
new file mode 100644
index 0000000..f2068e4
--- /dev/null
+++ b/libselinux/python-bindings/Makefile
@@ -0,0 +1,63 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Makefile of /CoreOS/libselinux/Sanity/python-bindings
+#   Description: Import selinux python module, check its metadata
+#   Author: Petr Lautrbach <plautrba@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2019 Red Hat, Inc.
+#
+#   This program is free software: you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation, either version 2 of
+#   the License, or (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be
+#   useful, but WITHOUT ANY WARRANTY; without even the implied
+#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#   PURPOSE.  See the GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+export TEST=/CoreOS/libselinux/Sanity/python-bindings
+export TESTVERSION=1.0
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install download clean
+
+run: $(FILES) build
+	./runtest.sh
+
+build: $(BUILT_FILES)
+	test -x runtest.sh || chmod a+x runtest.sh
+
+clean:
+	rm -f *~ $(BUILT_FILES)
+
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+	@echo "Owner:           Petr Lautrbach <plautrba@redhat.com>" > $(METADATA)
+	@echo "Name:            $(TEST)" >> $(METADATA)
+	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)
+	@echo "Path:            $(TEST_DIR)" >> $(METADATA)
+	@echo "Description:     Import selinux python module, check its metadata" >> $(METADATA)
+	@echo "Type:            Sanity" >> $(METADATA)
+	@echo "TestTime:        5m" >> $(METADATA)
+	@echo "RunFor:          libselinux" >> $(METADATA)
+	@echo "Requires:        python3-libselinux" >> $(METADATA)
+	@echo "Priority:        Normal" >> $(METADATA)
+	@echo "License:         GPLv2+" >> $(METADATA)
+	@echo "Confidential:    no" >> $(METADATA)
+	@echo "Destructive:     no" >> $(METADATA)
+	@echo "Releases:        -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA)
+
+	rhts-lint $(METADATA)

diff --git a/libselinux/python-bindings/PURPOSE b/libselinux/python-bindings/PURPOSE
new file mode 100644
index 0000000..cdeaf9c
--- /dev/null
+++ b/libselinux/python-bindings/PURPOSE
@@ -0,0 +1,3 @@
+PURPOSE of /CoreOS/libselinux/Sanity/python-bindings
+Description: Import selinux python module, check its metadata and try basic operation
+Author: Petr Lautrbach <plautrba@redhat.com>

diff --git a/libselinux/python-bindings/main.fmf b/libselinux/python-bindings/main.fmf
new file mode 100644
index 0000000..7481198
--- /dev/null
+++ b/libselinux/python-bindings/main.fmf
@@ -0,0 +1,7 @@
+path: /libselinux/python-bindings
+summary: Import selinux python module, check its metadata
+description: |
+    The test compares rpm version with python module metadata version and
+    tries to use selinux python module in a simple operation
+relevancy:
+    - "distro = rhel-4, rhel-5, rhel-6: rhel-7: False"

diff --git a/libselinux/python-bindings/runtest.sh b/libselinux/python-bindings/runtest.sh
new file mode 100755
index 0000000..a8e9b11
--- /dev/null
+++ b/libselinux/python-bindings/runtest.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   runtest.sh of /CoreOS/libselinux/Sanity/python-bindings
+#   Description: Import selinux python module, check its metadata
+#   Author: Petr Lautrbach <plautrba@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#   Copyright (c) 2019 Red Hat, Inc.
+#
+#   This program is free software: you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation, either version 2 of
+#   the License, or (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be
+#   useful, but WITHOUT ANY WARRANTY; without even the implied
+#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+#   PURPOSE.  See the GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program. If not, see http://www.gnu.org/licenses/.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# Include Beaker environment
+. /usr/bin/rhts-environment.sh || exit 1
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+PACKAGE="python3-libselinux"
+
+rlJournalStart
+    rlPhaseStartSetup
+        rlAssertRpm $PACKAGE
+        rlAssertRpm python3-pip
+        rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
+        rlRun "pushd $TmpDir"
+    rlPhaseEnd
+
+    rlPhaseStartTest "Check rpm and module metadata versions"
+        rlRun "RpmVersion=\$(rpm -q --qf 'Version: %{version}' python3-libselinux)"
+        rlRun "PipVersion=\$(pip3 show selinux | grep Version)"
+        rlAssertEquals "Is the python3-libselinux version same as the version of python selinux module" "$RpmVersion" "$PipVersion"
+    rlPhaseEnd
+
+    rlPhaseStartTest "Import selinux module and try selinux.is_selinux_enabled()"
+        rlRun "python3 -c 'import selinux'" 0
+	rlRun "python3 -c 'import selinux; rc = selinux.is_selinux_enabled(); sys.exit(rc)'" 0,1
+	rlRun "PYTHON_SELINUX_ENABLED=$?"
+	if selinuxenabled; then
+	    rlAssertEquals "SELinux is enabled" $PYTHON_SELINUX_ENABLED 1
+	else
+	    rlAssertNotEquals "SELinux is disabled" $PYTHON_SELINUX_ENABLED 0
+	fi
+    rlPhaseEnd
+
+    rlPhaseStartCleanup
+        rlRun "popd"
+        rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
+    rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd

                 reply	other threads:[~2026-09-11 13:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178913265259.1.1607613946897184129.tests-selinux-2e7483099e85@fedoraproject.org \
    --to=plautrba@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox