#4 add-rpm-macros-test
Closed 5 years ago by plautrba. Opened 6 years ago by mmalik.
https://github.com/milosmalik/fedora-selinux-tests.git add-rpm-macros-test  into  master

Adding the selinux-policy/policy-rpm-macros test
Milos Malik • 6 years ago  
selinux-policy/policy-rpm-macros/Makefile
file added
+66
@@ -0,0 +1,66 @@

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile of /CoreOS/selinux-policy/Sanity/policy-rpm-macros

+ #   Description: Are necessary RPM macros defined for various policy actions?

+ #   Author: Milos Malik <mmalik@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   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, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ export TEST=/CoreOS/selinux-policy/Sanity/policy-rpm-macros

+ 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:           Milos Malik <mmalik@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     Are necessary RPM macros defined for various policy actions?" >> $(METADATA)

+ 	@echo "Type:            Sanity" >> $(METADATA)

+ 	@echo "TestTime:        15m" >> $(METADATA)

+ 	@echo "RunFor:          selinux-policy" >> $(METADATA)

+ 	@echo "Requires:        selinux-policy /usr/sbin/semanage" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 	@echo "Releases:        -RHEL4 -RHEL6 -RHELClient5 -RHELServer5" >> $(METADATA)

+ 	@echo "Bug:             1380854" >> $(METADATA) # RHEL-7

+ 	@echo "Bug:             1415694" >> $(METADATA) # RHEL-7

+ 

+ 	rhts-lint $(METADATA)

+ 

selinux-policy/policy-rpm-macros/PURPOSE
file added
+9
@@ -0,0 +1,9 @@

+ PURPOSE of /CoreOS/selinux-policy/Sanity/policy-rpm-macros

+ Author: Milos Malik <mmalik@redhat.com>

+ 

+ Are necessary RPM macros defined for various policy actions? Are they defined correctly?

+ 

+ More information at:

+  * https://plautrba.fedorapeople.org/blok/Fedora-SELinux-module-packaging.html

+  * https://github.com/fedora-selinux/selinux-policy-macros/blob/master/README.adoc

+ 

selinux-policy/policy-rpm-macros/runtest.sh
file added
+71
@@ -0,0 +1,71 @@

+ #!/bin/bash

+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/selinux-policy/Sanity/policy-rpm-macros

+ #   Description: Are necessary RPM macros defined for various policy actions?

+ #   Author: Milos Malik <mmalik@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2017 Red Hat, Inc.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   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, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include Beaker environment

+ . /usr/bin/rhts-environment.sh || exit 1

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="selinux-policy"

+ MACRO_FILE="/usr/lib/rpm/macros.d/macros.selinux-policy"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm ${PACKAGE}

+         rlRun "ls -l ${MACRO_FILE}"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "Are the macros defined?"

+         rlRun "grep ^%selinux_modules_install ${MACRO_FILE}"

+         rlRun "grep ^%selinux_modules_uninstall ${MACRO_FILE}"

+         rlRun "grep ^%selinux_relabel_pre ${MACRO_FILE}"

+         rlRun "grep ^%selinux_relabel_post ${MACRO_FILE}"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "bz#1415694"

+         rlRun "grep selinuxenabled ${MACRO_FILE}"

+         rlRun "grep selinuxenabled ${MACRO_FILE} | grep _sbindir"

+         rlRun "grep selinuxenabled ${MACRO_FILE} | grep /usr/sbin/" 1

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "download and prepare the upstream test"

+         rlRun "git clone https://github.com/fedora-selinux/selinux-policy-macros.git"

+         rlRun "rm -f selinux-policy-macros/macros.selinux-policy"

+         rlRun "cp /usr/lib/rpm/macros.d/macros.selinux-policy selinux-policy-macros/"

+     rlPhaseEnd

+ 

+     pushd selinux-policy-macros

+     # running an upstream test written by Petr Lautrbach, thanks

+     ./runtest.sh

+     popd

+ 

+     rlPhaseStartCleanup

+         rlRun "rm -rf selinux-policy-macros"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

+ 

no initial comment

Adding the selinux-policy/policy-rpm-macros test

The selinux-policy defines various macros that are used by rpm/yum.
This is a wrapper for the selinux-policy-macros test suite located on github.com.

It looks like a requirement for semanage tool but this tools live in policycoreutils-python-utils

It looks like a private bug - You are not authorized to access bug #1488402.

rebased onto 78efd27

5 years ago

Pull-Request has been closed by plautrba

5 years ago