From f2a01782a3ac43a3d89fa4deaf04008d45291738 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 29 Oct 2024 11:20:37 +0100 Subject: [PATCH] test/check-systemd-unit: skip if systemd too old On RHEL 8, the --offline argument is not yet there. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2060 --- src/tests/check-systemd-unit.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/tests/check-systemd-unit.sh b/src/tests/check-systemd-unit.sh index 7e3f786e09..b16f2a3353 100755 --- a/src/tests/check-systemd-unit.sh +++ b/src/tests/check-systemd-unit.sh @@ -4,13 +4,19 @@ set -e set -o pipefail -# We're using "security" as opposed to "verify" because (as of 2024) -# the latter doesn't support --offline runs. -# -# The point is that if anything appears before the security report -# header, there's an error or a warning while parsing the unit file. -env -i systemd-analyze --offline=true security "$1" 2>&1 |awk ' - /NAME.*DESCRIPTION.*EXPOSURE/ {suppress=1} - {if (!suppress) {print; failed++}} - END {exit failed} -' +if systemd-analyze --offline=true security 2>/dev/null &1 |awk ' + /NAME.*DESCRIPTION.*EXPOSURE/ {suppress=1} + {if (!suppress) {print; failed++}} + END {exit failed} + ' + +else + echo "SKIP: systemd-analyze --offline=true security not supported" >&2 +fi