]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: ensure printf builtin buffers and does a single write when piping into socat
authorLuca Boccassi <luca.boccassi@gmail.com>
Tue, 5 Aug 2025 18:34:49 +0000 (19:34 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 5 Aug 2025 23:21:22 +0000 (00:21 +0100)
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 3998b30a040d1494918e11c78ef3eae72532bbca

Fixes https://github.com/systemd/systemd/issues/37626

test/units/TEST-50-DISSECT.dissect.sh

index ff8a5dd4c74e673baccdfb11e18a1606777e36f4..a5dc65e46949659aa2e49bb298b91b40a069d369 100755 (executable)
@@ -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; \