test: ensure printf builtin buffers and does a single write when piping into socat

Should hopefully solve this:

[  111.084463] systemd[1]: testservice-50k.service: Got notification message from PID 2651: RELOADING=1
[  111.085980] systemd[1]: testservice-50k.service: Got notification message from PID 2651: MONOTONIC_USEC=111072508

ie, pid1 receives RELOADING=1 and MONOTONIC_USEC= in different messages instead
of a single one, and reload-notify breaks

Follow-up for 3998b30a04

Fixes https://github.com/systemd/systemd/issues/37626
This commit is contained in:
Luca Boccassi
2025-08-05 19:34:49 +01:00
parent bebaaddd41
commit 2af77abb1c

View File

@@ -653,7 +653,7 @@ NotifyAccess=all
ExecStart=bash -x -c ' \
trap '"'"' \
now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \
printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
(ls /etc | grep marker) >/tmp/markers/50i; \
(cat /usr/lib/os-release) >>/tmp/markers/50i; \
echo "READY=1" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
@@ -688,7 +688,7 @@ NotifyAccess=all
ExecStart=bash -x -c ' \
trap '"'"' \
now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \
printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
(ls /etc | grep marker) >/tmp/markers/50j; \
(cat /usr/lib/os-release) >>/tmp/markers/50j; \
echo "READY=1" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
@@ -718,7 +718,7 @@ NotifyAccess=all
ExecStart=bash -x -c ' \
trap '"'"' \
now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \
printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
(ls /etc | grep marker) >/tmp/markers/50k; \
(cat /usr/lib/os-release) >>/tmp/markers/50k; \
echo "READY=1" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \