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.
This commit is contained in:
Jan Kurik 2022-03-07 08:16:01 +01:00
parent a361a6c70f
commit 347bfee468
4 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,68 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/pcp/Sanity/rpm-config-files
# Description: Verification of rpm config files
# Author: Jan Kuřík <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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 <jkurik@redhat.com>" > $(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)

View File

@ -0,0 +1,3 @@
PURPOSE of /tools/pcp/Sanity/rpm-config-files
Description: Verification of rpm config files
Author: Jan Kuřík <jkurik@redhat.com>

View File

@ -0,0 +1,13 @@
summary: Verification of rpm's config files
description: 'Verification of rpms config files'
contact: Jan Kuřík <jkurik@redhat.com>
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

View File

@ -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 <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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