Fix: Tests with racy event validation
authorChristian Babeux <christian.babeux@efficios.com>
Wed, 21 May 2014 19:19:22 +0000 (15:19 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 21 May 2014 19:58:54 +0000 (15:58 -0400)
Similar to d7ee608c00feacea3cfd5a740df64e5215347cb9, make sure that the
event validation scheme is not racy. If we need to wait for applications
to complete simply start them in foreground or use the built-in 'wait'
command in bash to wait for applications started in background.

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
tests/regression/tools/live/test_lttng_ust
tests/regression/tools/live/test_ust
tests/regression/tools/live/test_ust_tracefile_count
tests/regression/tools/streaming/test_ust
tests/regression/ust/before-after/test_before_after
tests/regression/ust/buffers-pid/test_buffers_pid
tests/regression/ust/multi-session/test_multi_session

index db63b4b8757ebead092a3ac6604665f1b951b3db..8a1aec639aafad4f1f6d366f6b5dc3ad7dcd1e91 100755 (executable)
@@ -78,11 +78,7 @@ start_lttng_relayd "-o $TRACE_PATH"
 setup_live_tracing
 
 # Run app in background
-$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
-# Wait for app to complete
-while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-       sleep 0.5
-done
+$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
 
 clean_live_tracing
 
index d4110ceafdc86db147b4819ea1cd2e6621764939..2eac48c6eee8d71a822eb70e9661829b9d019224 100755 (executable)
@@ -81,11 +81,7 @@ fi
 setup_live_tracing
 
 # Run app in background
-$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
-# Wait for app to complete
-while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-       sleep 0.5
-done
+$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
 
 # Start the live test
 $TESTDIR/regression/tools/live/live_test
index 464f4aacb69b60fe1879e88c520863c994d7802d..f90cbd1ebd42241c0b4e9426a1345583901bae98 100755 (executable)
@@ -82,11 +82,7 @@ fi
 setup_live_tracing
 
 # Run app in background
-$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
-# Wait for app to complete
-while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-       sleep 0.5
-done
+$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
 
 # Start the live test
 $TESTDIR/regression/tools/live/live_test
index 785a9a8353efe813dc6fd66f318386f8afa3684e..4c7ac976f870abc8029b4ddc5d5bbb1b076de6b9 100755 (executable)
@@ -29,7 +29,7 @@ PID_RELAYD=0
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=18
+NUM_TESTS=16
 
 source $TESTDIR/utils/utils.sh
 
@@ -44,13 +44,6 @@ function lttng_create_session_uri
        ok $? "Create session with default path"
 }
 
-function wait_apps
-{
-       while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-               sleep 0.5
-       done
-       pass "Wait for applications to end"
-}
 
 # MUST set TESTDIR before calling those functions
 
@@ -64,8 +57,8 @@ function test_ust_before_start ()
        $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
 
        start_lttng_tracing $SESSION_NAME
-
-       wait_apps
+       # Wait for the applications started in background
+       wait ${!}
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
@@ -79,9 +72,7 @@ function test_ust_after_start ()
        start_lttng_tracing $SESSION_NAME
 
        # Run 5 times with a 1 second delay
-       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
-
-       wait_apps
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
index ed4981ba0f55d3f96cd6c5a3c559b96a0eb8f32b..66858517a6b38c2d7f18e7954d0f25c94e63b036 100755 (executable)
@@ -25,7 +25,7 @@ TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 SESSION_NAME="per-session"
 EVENT_NAME="tp:tptest"
-NUM_TESTS=17
+NUM_TESTS=16
 
 source $TESTDIR/utils/utils.sh
 
@@ -35,14 +35,6 @@ fi
 
 # MUST set TESTDIR before calling those functions
 
-function wait_app()
-{
-       while [ -n "$(pidof $TESTAPP_NAME)" ]; do
-               sleep 0.5
-       done
-       pass "Application $TESTAPP_NAME ended."
-}
-
 function test_before_apps()
 {
        # BEFORE application is spawned
@@ -65,19 +57,15 @@ function test_after_apps()
 {
        local out
 
+       create_lttng_session $SESSION_NAME $TRACE_PATH
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+
        $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
        ok $? "Application started in background."
 
-       # BEFORE application is spawned
-       create_lttng_session $SESSION_NAME $TRACE_PATH
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
        start_lttng_tracing $SESSION_NAME
 
-       # Since the start is done after the application is started, there is a
-       # bootstrap time needed between the session daemon and the UST tracer.
-       # Waiting for the application to end tells us when to stop everything and
-       # validate that at least one event is seen.
-       wait_app
+       wait ${!}
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
index 1cf3cb23ead5843a32541028505c51c1a3994f4e..6fab526c111c88ec3a7d5a3e43c5f20e00566de7 100755 (executable)
@@ -144,17 +144,18 @@ test_before_app() {
 
        diag "Start application BEFORE tracing is started"
 
-       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
-       ok $? "Start application to trace"
 
        # BEFORE application is spawned
        create_lttng_session $SESSION_NAME $TRACE_PATH
        enable_channel_per_pid $SESSION_NAME "channel0"
        enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
+
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
+       ok $? "Start application to trace"
+
        start_lttng_tracing $SESSION_NAME
 
-       # At least hit one event
-       sleep 2
+       wait ${!}
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
@@ -170,8 +171,6 @@ test_before_app() {
                out=0
        fi
 
-       wait_apps
-
        return $out
 }
 
index 313a7d70fa9c408d529d4fca80a2a56d5c0233d2..19f8d4288ed8c7a50ad0ade87202b04feda38a44 100755 (executable)
@@ -44,11 +44,7 @@ test_multi_session() {
        ./$CURDIR/gen-nevents $NR_ITER &
        ok $? "Start application to generate $NR_ITER events"
 
-       # At least hit one event
-       while [ -n "$(pidof gen-nevents)" ]; do
-               sleep 0.1
-       done
-
+       wait ${!}
        pass "Wait for events to record"
 
        for i in `seq 0 3`; do
This page took 0.029503 seconds and 4 git commands to generate.