From b263d4070b0c80ab86a04882396ec660c0ded586 Mon Sep 17 00:00:00 2001 From: Jan Kurik Date: Wed, 10 Nov 2021 16:11:00 +0100 Subject: [PATCH] Improvement of the systemd unit files test Make the systemd unit files test more robus, to avoid false positives in case there are non-unit files in the sytemd directory. --- tests/Sanity/verify-systemd-units/runtest.sh | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/Sanity/verify-systemd-units/runtest.sh b/tests/Sanity/verify-systemd-units/runtest.sh index bb3001f..8901b1f 100755 --- a/tests/Sanity/verify-systemd-units/runtest.sh +++ b/tests/Sanity/verify-systemd-units/runtest.sh @@ -31,6 +31,7 @@ PACKAGE="pcp" PKGS="pcp pcp-zeroconf" UNITS="" +UNITFILESDIR="/usr/lib/systemd/system/" rlJournalStart rlPhaseStartSetup @@ -42,20 +43,24 @@ rlJournalStart rlAssertRpm "${P}" done # Generate list of unit files - UNITS="$(rpm -ql ${PKGS} | grep /usr/lib/systemd/system/)" + UNITS=$(rpm -ql ${PKGS} | grep "${UNITFILESDIR}") rlLog "Available unit files: ${UNITS}" rlPhaseEnd rlPhaseStartTest FAILEDU="" for U in ${UNITS}; do - if ! rlRun -s "systemd-analyze --no-pager verify ${U}"; then - rlFail "Error in ${U}: $(cat ${rlRun_LOG})" - FAILEDU="${FAILEDU} $(basename ${U})" - fi - if grep -q 'is deprecated' ${rlRun_LOG}; then - rlFail "Error in ${U}: $(cat ${rlRun_LOG})" - FAILEDU="${FAILEDU} $(basename ${U})" + if [[ -f ${U} ]] && [[ "$(dirname ${U})" == "${UNITFILESDIR%/}" ]]; then + if ! rlRun -s "systemd-analyze --no-pager verify ${U}"; then + rlFail "Error in ${U}: $(cat ${rlRun_LOG})" + FAILEDU="${FAILEDU} $(basename ${U})" + fi + if grep -q 'is deprecated' ${rlRun_LOG}; then + rlFail "Error in ${U}: $(cat ${rlRun_LOG})" + FAILEDU="${FAILEDU} $(basename ${U})" + fi + else + rlLog "${U} is not a regular unit file ... skipping" fi done [[ -n "${FAILEDU}" ]] && rlLog "List of failed units: ${FAILEDU}"