]> git.lttng.org Git - lttng-tools.git/commitdiff
Fix: tests: don't use pidof to wait for test apps
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 19 Nov 2014 21:40:25 +0000 (22:40 +0100)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 21 Jan 2015 03:28:36 +0000 (22:28 -0500)
Use the bash shell "wait" to wait for all background tasks rather than
the racy "pidof". Indeed, it's possible that applications have been
forked, but not executed yet, when pidof is done, which would therefore
miss applications. Using "wait" from the shell solves this.

If we want to be really strict, we should have sessiond, consumerd, and
relayd export a file containing their own PID, and wait for this instead
of using pidof. But this will be for another fix.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/snapshots/test_ust_streaming
tests/regression/tools/snapshots/ust_test
tests/regression/tools/streaming/test_high_throughput_limits
tests/regression/ust/buffers-pid/test_buffers_pid
tests/regression/ust/high-throughput/test_high_throughput
tests/regression/ust/nprocesses/test_nprocesses
tests/regression/ust/periodical-metadata-flush/test_periodical_metadata_flush

index 632a563e06502e07303c3ece0a4232352eee5b1f..c0d98c2df1ff0dfb686b7ac7c23eb06ea8d9443c 100755 (executable)
@@ -72,6 +72,15 @@ function start_trace_app()
        rm -f $tmp_file
 }
 
+function stop_trace_app()
+{
+       diag "Killing $TESTAPP_NAME"
+       PID_APP=`pidof $TESTAPP_NAME`
+       kill $PID_APP >/dev/null 2>&1
+       diag "Waiting on $TESTAPP_NAME"
+       wait
+}
+
 # Test a snapshot using a default name for the output destination.
 function test_ust_default_name_with_del()
 {
@@ -90,6 +99,7 @@ function test_ust_default_name_with_del()
        echo $TRACE_PATH/$HOSTNAME/snapshot-1
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
        if [ $? -ne 0 ]; then
+               stop_trace_app
                return $?
        fi
 
@@ -100,15 +110,14 @@ function test_ust_default_name_with_del()
        # Validate test with the next ID since a del output was done prior.
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2*
        if [ $? -ne 0 ]; then
+               stop_trace_app
                return $?
        fi
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       diag "Killing $TESTAPP_NAME"
-       PID_APP=`pidof $TESTAPP_NAME`
-       kill $PID_APP >/dev/null 2>&1
+       stop_trace_app
 
        return 0
 }
@@ -132,9 +141,7 @@ function test_ust_default_name()
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
        out=$?
 
-       diag "Killing $TESTAPP_NAME"
-       PID_APP=`pidof $TESTAPP_NAME`
-       kill $PID_APP >/dev/null 2>&1
+       stop_trace_app
 
        return $out
 }
@@ -157,9 +164,7 @@ function test_ust_default_name_custom_uri()
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
        out=$?
 
-       diag "Killing $TESTAPP_NAME"
-       PID_APP=`pidof $TESTAPP_NAME`
-       kill $PID_APP >/dev/null 2>&1
+       stop_trace_app
 
        return $out
 }
@@ -193,9 +198,7 @@ function test_ust_custom_name()
                out=1
        fi
 
-       diag "Killing $TESTAPP_NAME"
-       PID_APP=`pidof $TESTAPP_NAME`
-       kill $PID_APP >/dev/null 2>&1
+       stop_trace_app
 
        return $out
 }
index 128849ef8ce7c87618aea7d361803c79ab38307a..0a9e244d814b45c2130bbd2e81172d88269290dd 100755 (executable)
@@ -63,11 +63,13 @@ function start_test_app()
        rm -f $tmp_file
 }
 
-function kill_test_app()
+function stop_test_app()
 {
        diag "Killing $TESTAPP_NAME"
        PID_APP=`pidof $TESTAPP_NAME`
        kill $PID_APP >/dev/null 2>&1
+       diag "Waiting on $TESTAPP_NAME"
+       wait
 }
 
 function snapshot_add_output ()
@@ -170,7 +172,7 @@ function test_ust_local_snapshot ()
                rm -rf $TRACE_PATH
        fi
 
-       kill_test_app
+       stop_test_app
 }
 
 function test_ust_local_snapshot_max_size ()
@@ -218,7 +220,7 @@ function test_ust_local_snapshot_max_size ()
                rm -rf $TRACE_PATH
        fi
 
-       kill_test_app
+       stop_test_app
 }
 
 function test_ust_local_snapshot_large_metadata ()
@@ -280,7 +282,7 @@ function test_ust_per_uid_local_snapshot ()
                rm -rf $TRACE_PATH
        fi
 
-       kill_test_app
+       stop_test_app
 }
 
 function test_ust_per_uid_local_snapshot_post_mortem ()
@@ -294,7 +296,7 @@ function test_ust_per_uid_local_snapshot_post_mortem ()
 
        # Returns once the application has at least fired ONE tracepoint.
        start_test_app
-       kill_test_app
+       stop_test_app
 
        lttng_snapshot_record $SESSION_NAME
        stop_lttng_tracing $SESSION_NAME
@@ -334,7 +336,7 @@ function test_ust_local_snapshots ()
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       kill_test_app
+       stop_test_app
 }
 
 plan_tests $NUM_TESTS
index b2c8864cafc6c0d70a8f1d2727fd271748f9b255..8ed2ce53c8b85651fe77dacbdf55616aa6ac5caa 100755 (executable)
@@ -33,7 +33,7 @@ DEFAULT_IF="lo"
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=112
+NUM_TESTS=104
 
 source $TESTDIR/utils/utils.sh
 
@@ -95,14 +95,6 @@ function run_apps
        done
 }
 
-function wait_apps
-{
-       while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-               sleep 1
-       done
-       pass "Wait for applications to end"
-}
-
 function test_high_throughput
 {
        NETWORK_URI="net://localhost"
@@ -110,7 +102,9 @@ function test_high_throughput
        enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
        start_lttng_tracing $SESSION_NAME
        run_apps
-       wait_apps
+       diag "Waiting for applications to end"
+       wait
+       pass "waiting done"
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
        validate_event_count
index 1cf3cb23ead5843a32541028505c51c1a3994f4e..a788f869418ba70cb95819d5c09a9c2e440693a5 100755 (executable)
@@ -26,7 +26,7 @@ TESTAPP_PATH="$TESTDIR/utils/testapp"
 TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 EVENT_NAME="tp:tptest"
-NUM_TESTS=58
+NUM_TESTS=59
 
 source $TESTDIR/utils/utils.sh
 
@@ -45,14 +45,6 @@ function enable_channel_per_pid()
        ok $? "Enable channel $channel_name per PID for session $sess_name"
 }
 
-function wait_apps
-{
-       diag "Waiting for applications to end..."
-       while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-               sleep 1
-       done
-}
-
 test_after_multiple_apps() {
        local out
        local i
@@ -95,8 +87,9 @@ test_before_multiple_apps() {
        enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
        start_lttng_tracing $SESSION_NAME
 
-       # At least hit one event
-       sleep 2
+       diag "Waiting for applications to end"
+       wait
+       pass "Waiting done"
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
@@ -112,8 +105,6 @@ test_before_multiple_apps() {
                out=0
        fi
 
-       wait_apps
-
        return $out
 }
 
index ea450511ae02ddef07bd142e00c240de8ae75b46..101a2c0a62250369876d30d73856279d002d4c5d 100755 (executable)
@@ -49,10 +49,9 @@ for i in `seq 1 $NR_APP`; do
        ./$CURDIR/$BIN_NAME & >/dev/null 2>&1
 done
 
-while [ -n "$(pidof $BIN_NAME)" ]; do
-       sleep 0.5
-done
-pass "Wait for application end"
+diag "Waiting for applications to end"
+wait
+pass "Wait for applications to end"
 
 stop_lttng_tracing $SESSION_NAME
 destroy_lttng_session $SESSION_NAME
index 1660c219bae9a3a0e052b7f87e655a760a9d68cc..84d0ff7a03a8d92eaaacd474975ede1d16086370 100755 (executable)
@@ -75,12 +75,9 @@ destroy_lttng_session $SESSION_NAME
 
 rm -rf $TRACE_PATH
 
-while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-       killall -q $TESTAPP_NAME >/dev/null 2>&1
-       sleep 0.5
-done
-
-
-pass "Kill all spawned applications"
+diag "Stopping all spawned applications"
+killall -q $TESTAPP_NAME >/dev/null 2>&1
+wait
+pass "Stopped all spawned applications"
 
 stop_lttng_sessiond
index e836956437cff90e1dbab7447c84a054ef334c5d..e4199652bce1a456333ca0d88cbe869a5b590f96 100755 (executable)
@@ -73,14 +73,6 @@ function enable_metadata_per_pid()
        ok $? "Enable channel $channel_name per PID for session $sess_name"
 }
 
-function wait_apps
-{
-       diag "Waiting for applications to end..."
-       while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-               sleep 1
-       done
-}
-
 function validate_trace()
 {
        local out
@@ -149,11 +141,11 @@ test_after_app_pid() {
        validate_trace
        out=$?
 
+       killall -SIGKILL -q $TESTAPP_NAME
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       killall -SIGKILL -q $TESTAPP_NAME
-       wait_apps
+       wait
 
        return $out
 }
@@ -188,11 +180,11 @@ test_before_app_pid() {
        validate_trace
        out=$?
 
+       killall -SIGKILL -q $TESTAPP_NAME
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       killall -SIGKILL -q $TESTAPP_NAME
-       wait_apps
+       wait
 
        return $out
 }
@@ -223,11 +215,11 @@ test_after_app_uid() {
        validate_trace
        out=$?
 
+       killall -SIGKILL -q $TESTAPP_NAME
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       killall -SIGKILL -q $TESTAPP_NAME
-       wait_apps
+       wait
 
        return $out
 }
@@ -261,11 +253,11 @@ test_before_app_uid() {
        validate_trace
        out=$?
 
+       killall -SIGKILL -q $TESTAPP_NAME
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       killall -SIGKILL -q $TESTAPP_NAME
-       wait_apps
+       wait
 
        return $out
 }
This page took 0.039271 seconds and 4 git commands to generate.