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
This commit is contained in:
Lubomir Rintel
2024-10-29 11:20:37 +01:00
parent afab26a8fa
commit f2a01782a3

View File

@@ -4,13 +4,19 @@
set -e set -e
set -o pipefail set -o pipefail
# We're using "security" as opposed to "verify" because (as of 2024) if systemd-analyze --offline=true security 2>/dev/null </dev/null; then
# the latter doesn't support --offline runs.
# # We're using "security" as opposed to "verify" because (as of 2024)
# The point is that if anything appears before the security report # the latter doesn't support --offline runs.
# header, there's an error or a warning while parsing the unit file. #
env -i systemd-analyze --offline=true security "$1" 2>&1 |awk ' # The point is that if anything appears before the security report
/NAME.*DESCRIPTION.*EXPOSURE/ {suppress=1} # header, there's an error or a warning while parsing the unit file.
{if (!suppress) {print; failed++}} env -i systemd-analyze --offline=true security "$1" 2>&1 |awk '
END {exit failed} /NAME.*DESCRIPTION.*EXPOSURE/ {suppress=1}
' {if (!suppress) {print; failed++}}
END {exit failed}
'
else
echo "SKIP: systemd-analyze --offline=true security not supported" >&2
fi