From 996ad55fbc176fe6f97f0ef64fefb6845a7d917d Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Thu, 9 Jan 2020 16:36:35 -0500 Subject: [PATCH] tests: delay reading of pidfile if found empty Delay the reading of the PID file if it is found to be empty. This can happend if swtpm is run by valgrind. Also, use the passed parameters rather than the global ones to check the PID file contents against the expected pid. So far this worked because PID and PID_FILE were variables used by every caller. Signed-off-by: Stefan Berger --- tests/common | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/common b/tests/common index 6d85983f..aa5db42d 100644 --- a/tests/common +++ b/tests/common @@ -735,8 +735,14 @@ function validate_pidfile() { local pid="$1" local pidfile="$2" + local rpid="$(cat $pidfile)" - if [ "$PID" != "$(cat $PID_FILE)" ]; then + if [ -z "$rpid" ]; then + sleep 0.1 + rpid="$(cat $pidfile)" + fi + + if [ "$pid" != "$rpid" ]; then echo "Error: pid file contains unexpected PID value." echo "expected: $pid" echo "actual : $(cat $pidfile)"