From: Kienan Stewart Date: Thu, 14 Nov 2024 21:14:08 +0000 (-0500) Subject: Tests/Docs: Update recommendations on waiting on applications X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=65df1e4a889c920fcf6249b1b84630111ec71b58;p=lttng-tools.git Tests/Docs: Update recommendations on waiting on applications Change-Id: I0d79924b45f3cfa032348f2c90ffb8f80aa2b42c Signed-off-by: Kienan Stewart Signed-off-by: Jérémie Galarneau --- 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