From 347bfee46850d4dc26a1a1d46c7395c4b588479d Mon Sep 17 00:00:00 2001 From: Jan Kurik Date: Mar 07 2022 07:16:01 +0000 Subject: Implementation of rpm-config-files test case The testcase check whether all config files delivered by pcp RPM's are marked as '%config' in spec file. --- diff --git a/tests/Sanity/rpm-config-files/Makefile b/tests/Sanity/rpm-config-files/Makefile new file mode 100644 index 0000000..e2fa1b6 --- /dev/null +++ b/tests/Sanity/rpm-config-files/Makefile @@ -0,0 +1,68 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/pcp/Sanity/rpm-config-files +# Description: Verification of rpm config files +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 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=/tools/pcp/Sanity/rpm-config-files +export TESTVERSION=1.0 +export TEST_GIT_REF ?= main +export TEST_GIT_URL ?= https://src.fedoraproject.org/rpms/pcp.git +export TEST_GIT_PATH ?= tests/Sanity/rpm-config-files +export TEST_GIT_SCRIPT ?= ./runtest.sh +export GIT_SSL_NO_VERIFY=true + + +BUILT_FILES= + +FILES=$(METADATA) Makefile PURPOSE runtest.sh + +.PHONY: all install download clean + +run: $(FILES) + chmod +x ./runtest.sh + ./runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Jan Kuřík " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Verification of rpm config files" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 30m" >> $(METADATA) + @echo "RunFor: pcp" >> $(METADATA) + @echo "Requires: pcp rpm-build" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Bug: 1963938 1964253" >> $(METADATA) + @echo "Releases: -RHEL4 -RHEL6 -RHELClient5 -RHELServer5 -RHEL7" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Sanity/rpm-config-files/PURPOSE b/tests/Sanity/rpm-config-files/PURPOSE new file mode 100644 index 0000000..91c591f --- /dev/null +++ b/tests/Sanity/rpm-config-files/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/pcp/Sanity/rpm-config-files +Description: Verification of rpm config files +Author: Jan Kuřík diff --git a/tests/Sanity/rpm-config-files/main.fmf b/tests/Sanity/rpm-config-files/main.fmf new file mode 100644 index 0000000..2e12b7f --- /dev/null +++ b/tests/Sanity/rpm-config-files/main.fmf @@ -0,0 +1,13 @@ +summary: Verification of rpm's config files +description: 'Verification of rpms config files' +contact: Jan Kuřík +component: +- pcp +test: ./runtest.sh +framework: beakerlib +recommend: +- pcp +- rpm-build +duration: 15m +extra-summary: /tools/pcp/Sanity/rpm-config-files +extra-task: /tools/pcp/Sanity/rpm-config-files diff --git a/tests/Sanity/rpm-config-files/runtest.sh b/tests/Sanity/rpm-config-files/runtest.sh new file mode 100755 index 0000000..c36848f --- /dev/null +++ b/tests/Sanity/rpm-config-files/runtest.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/pcp/Sanity/rpm-config-files +# Description: Verification of rpm config files +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 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/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="pcp" + +rlJournalStart + rlPhaseStartSetup + rlRun "T=\$(mktemp -d /var/tmp/XXXXXXXXXXXX)" + rlRun "pushd ${T}" || rlDie 'Something is wrong .... giving up...' + + # Get list of rpms + rlFetchSrcForInstalled --quiet "${PACKAGE}" || \ + rlDie 'Can not get source package of ${PACKAGE} .... giving up...' + SOURCEPKG=$(rpm -q --qf '%{name}-%{version}-%{release}.src.rpm' ${PACKAGE}) + rlAssertExists "${T}/${SOURCEPKG}" + rlRun "rpm -D '_topdir ${T}' -i ${T}/${SOURCEPKG}" + rlRun "RPMS=\$(rpm -q --qf '%{name}\n' --specfile ${T}/SPECS/${PACKAGE}.spec | \ + grep -v -e '-debuginfo' -e '-debugsource' | tr '\n' ' ')" + rlPhaseEnd + + rlPhaseStartTest "Install and test all ${PACKAGE} rpms" + rlRun "yum install -y ${RPMS}" + for p in ${RPMS}; do + configs=$(rpm -qc ${p}) + etc=$(rpm -ql ${p} | grep '^/etc/') + for f in ${etc}; do + if ! grep -q "${f}" <<< "${configs}"; then + [[ -f "${f}" ]] && [[ ! -h "${f}" ]] && rlFail \ + "File ${f} from ${p} package is not marked as a config file" + fi + done + done + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" # pushd ${T} + rlRun "rm -rf ${T}" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd