From 65df1e4a889c920fcf6249b1b84630111ec71b58 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Thu, 14 Nov 2024 16:14:08 -0500 Subject: [PATCH] Tests/Docs: Update recommendations on waiting on applications MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I0d79924b45f3cfa032348f2c90ffb8f80aa2b42c Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- tests/README.adoc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/README.adoc b/tests/README.adoc index 10adcb75e..ba8fa2eba 100644 --- a/tests/README.adoc +++ b/tests/README.adoc @@ -169,8 +169,20 @@ by kill and wait. Why is it flaky ? -It just waits for the last application put in background. Use -"wait" to wait for all background applications. +It just waits for the last application put in background. Track the PIDs +of the applications of interest in an array and use a construction similar +to the following to wait for them: + +``` +## Avoid running `wait ` when the array is empty +if [[ -n "${pids[*]}" ]]; then + wait "${pids[@]}"` +fi +``` + +Avoid `wait` without arguments as it will wait for other background +prcesses such as lttng-relayd or lttng-sessiond when they are started +without daemonization. === Forgetting wait at the end (or error return path) of a test phase that has background applications -- 2.39.5