From: Jonathan Rajotte Date: Tue, 15 Oct 2019 20:50:46 +0000 (-0400) Subject: Tests: use "kill -0" for app existence check in NS tests X-Git-Tag: v2.12.0-rc1~279 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=70a7f9f74ac7fc5717056ff083eb7df905a056af;p=lttng-tools.git Tests: use "kill -0" for app existence check in NS tests Removing the sleep 0.5 we hit a race where the "-f /proc/$pid_app" test returns false immediately. Using "kill -0" protects us against such races. From kill (2): If sig is 0, then no signal is sent, but existence and permission checks are still performed; this can be used to check for the existence of a process ID or process group ID that the caller is permitted to signal. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- diff --git a/tests/regression/kernel/test_ns_contexts_change b/tests/regression/kernel/test_ns_contexts_change index 905f6cf2b..08150244d 100755 --- a/tests/regression/kernel/test_ns_contexts_change +++ b/tests/regression/kernel/test_ns_contexts_change @@ -119,13 +119,11 @@ function test_ns() touch "$file_sync_wait_before_unshare" - # Let the app do it's thing before entering the synchronisation loop - sleep 0.5 - while [ ! -f "$file_sync_signal_after_unshare" ]; do # Break if the app failed / died - if [ ! -f "/proc/$app_pid" ]; then + if ! kill -0 "$app_pid" ; then break + echo "# App failed" fi echo "# Waiting for app..." sleep 0.5 diff --git a/tests/regression/ust/namespaces/test_ns_contexts_change b/tests/regression/ust/namespaces/test_ns_contexts_change index 18a22e588..0e03d5393 100755 --- a/tests/regression/ust/namespaces/test_ns_contexts_change +++ b/tests/regression/ust/namespaces/test_ns_contexts_change @@ -72,12 +72,10 @@ function test_ns() $TESTAPP_BIN -n "$ns" -i $NUM_EVENT -a "$file_sync_after_unshare" -b "$file_sync_before_last" & app_pid=$! - # Let the app do it's thing before entering the synchronisation loop - sleep 0.5 - while [ ! -f "$file_sync_after_unshare" ]; do # Break if the app failed / died - if [ ! -f "/proc/$app_pid" ]; then + if ! kill -0 "$app_pid" ; then + echo "# App failed" break fi echo "# Waiting for app..."