]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-80-NOTIFYACCESS: introduce test for ERRNO= + BUS/VARLINKERROR= 33430/head
authorMike Yuan <me@yhndnzj.com>
Thu, 20 Jun 2024 16:39:52 +0000 (18:39 +0200)
committerMike Yuan <me@yhndnzj.com>
Thu, 20 Jun 2024 18:51:12 +0000 (20:51 +0200)
test/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/test.sh
test/units/TEST-80-NOTIFYACCESS.sh

index 565ed8d35ac9eddd425d627f37ca271d3f4f65b8..47333ef0deb6862a6fa44ce519f000b140db8bc2 100755 (executable)
@@ -54,10 +54,21 @@ sync_in b
 
 echo "toplevel again: $BASHPID"
 
-systemd-notify --ready --status="OK"
+systemd-notify --ready
+systemd-notify "ERRNO=1" "BUSERROR=org.freedesktop.DBus.Error.InvalidArgs" "VARLINKERROR=org.varlink.service.InvalidParameter"
+
+sync_out e
+sync_in f
+
+systemd-notify "ERRNO=bogus" "BUSERROR=草wwww" "VARLINKERROR=systemköttel"
+
+sync_out g
+sync_in h
+
+systemd-notify --status="OK"
 systemd-notify "NOTIFYACCESS=none"
 systemd-notify --status="BOGUS3"
 
-sync_out e
+sync_out i
 
 exec sleep infinity
index 97b222a9e8932f3758317548648aabcde76822dd..355f6e7e30734401113ab6b5b2916af69b8f8514 100755 (executable)
@@ -20,6 +20,8 @@ sync_out() {
 
 export SYSTEMD_LOG_LEVEL=debug
 
+# Test NotifyAccess= override through sd_notify()
+
 systemctl --no-block start notify.service
 
 sync_in a
@@ -38,6 +40,22 @@ sync_out d
 sync_in e
 
 systemctl --quiet is-active notify.service
+[[ "$(systemctl show notify.service -P StatusText)" != BOGUS* ]]
+
+assert_eq "$(systemctl show notify.service -P StatusErrno)" "1"
+assert_eq "$(systemctl show notify.service -P StatusBusError)" "org.freedesktop.DBus.Error.InvalidArgs"
+assert_eq "$(systemctl show notify.service -P StatusVarlinkError)" "org.varlink.service.InvalidParameter"
+
+sync_out f
+sync_in g
+
+assert_eq "$(systemctl show notify.service -P StatusErrno)" "1"
+assert_eq "$(systemctl show notify.service -P StatusBusError)" "org.freedesktop.DBus.Error.InvalidArgs"
+assert_eq "$(systemctl show notify.service -P StatusVarlinkError)" "org.varlink.service.InvalidParameter"
+
+sync_out h
+sync_in i
+
 assert_eq "$(systemctl show notify.service -p StatusText --value)" "OK"
 assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "none"
 
@@ -46,6 +64,12 @@ assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "all"
 
 rm /tmp/syncfifo1 /tmp/syncfifo2
 
+# Explicitly test busctl's BUSERROR= reporting and systemctl status should show it
+
+(! systemd-run --wait --unit="TEST-80-BUSERROR.service" -p NotifyAccess=main busctl introspect org.freedesktop.systemd1 /bogus/001)
+assert_eq "$(systemctl show TEST-80-BUSERROR.service -P StatusBusError)" "org.freedesktop.DBus.Error.UnknownObject"
+assert_in "D-Bus: org.freedesktop.DBus.Error.UnknownObject" "$(systemctl status TEST-80-BUSERROR.service)"
+
 # Now test basic fdstore behaviour
 
 MYSCRIPT="/tmp/myscript$RANDOM.sh"