summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRyan Wilson <ryantimwilson@meta.com>2024-09-11 22:51:09 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-09-12 22:19:48 +0200
commitb0b4e39a4dc5c4f1ef501b844699eb7ea7877032 (patch)
tree64a2f13fe6a122dcbd4b8ab18e414c88c5b903af /test
parentunits: Order ldconfig.service after systemd-confext.service (diff)
downloadsystemd-b0b4e39a4dc5c4f1ef501b844699eb7ea7877032.tar.xz
systemd-b0b4e39a4dc5c4f1ef501b844699eb7ea7877032.zip
analyze: add test for verify exit status with warnings
Diffstat (limited to 'test')
-rwxr-xr-xtest/units/TEST-65-ANALYZE.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/units/TEST-65-ANALYZE.sh b/test/units/TEST-65-ANALYZE.sh
index db1cc585c7..76db01d68a 100755
--- a/test/units/TEST-65-ANALYZE.sh
+++ b/test/units/TEST-65-ANALYZE.sh
@@ -381,6 +381,29 @@ systemd-analyze verify /tmp/multi-exec-start.service
echo 'ExecStart=command-should-not-exist' >>/tmp/multi-exec-start.service
(! systemd-analyze verify /tmp/multi-exec-start.service)
+# Prevent regression from #20233 where systemd-analyze will return nonzero exit codes on warnings
+
+# Unit file with warning "Unknown key name 'foo' in section 'Unit', ignoring"
+cat <<EOF >/tmp/testwarnings.service
+[Unit]
+Foo=Bar
+
+[Service]
+ExecStart=echo hello
+EOF
+
+# yes/no/one should all return nonzero exit status for warnings in unit file
+(! systemd-analyze verify --recursive-errors=yes /tmp/testwarnings.service)
+
+(! systemd-analyze verify --recursive-errors=no /tmp/testwarnings.service)
+
+(! systemd-analyze verify --recursive-errors=one /tmp/testwarnings.service)
+
+# zero exit status since no errors and only warnings
+systemd-analyze verify /tmp/testwarnings.service
+
+rm /tmp/testwarnings.service
+
# Added an additional "INVALID_ID" id to the .json to verify that nothing breaks when input is malformed
# The PrivateNetwork id description and weight was changed to verify that 'security' is actually reading in
# values from the .json file when required. The default weight for "PrivateNetwork" is 2500, and the new weight