From 7e8cfa4bb6360740528c3c7c152db853f095af8b Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Fri, 9 Jul 2021 15:22:41 +0200 Subject: [PATCH] test: make the strace check a bit more clever 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/units/testsuite-36.sh b/test/units/testsuite-36.sh index 94fd927a5d1..b684011785f 100755 --- a/test/units/testsuite-36.sh +++ b/test/units/testsuite-36.sh @@ -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() { -- 2.47.3