]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: make the strace check a bit more clever 20185/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 9 Jul 2021 13:22:41 +0000 (15:22 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 9 Jul 2021 13:26:07 +0000 (15:26 +0200)
We still sometimes try to grep an empty strace log because strace is not
yet properly initialized. Let's make the check a bit clever and wait
until strace is attached to PID 1 by checking the `TracerPid` field in
`/proc/1/status`.

test/units/testsuite-36.sh

index 94fd927a5d13c16446ea2cecda574f3f1df2e33e..b684011785feeab1df629c5b9723208096786aef 100755 (executable)
@@ -34,8 +34,9 @@ journalCursorFile="jounalCursorFile"
 
 startStrace() {
     coproc strace -qq -p 1 -o "$straceLog" -e set_mempolicy -s 1024 ${1:+"$1"}
-    # Wait for strace to properly "initialize"
-    sleep $sleepAfterStart
+    # Wait for strace to properly "initialize", i.e. until PID 1 has the TracerPid
+    # field set to the current strace's PID
+    while ! awk -v spid="$COPROC_PID" '/^TracerPid:/ {exit !($2 == spid);}' /proc/1/status; do sleep 0.1; done
 }
 
 stopStrace() {