Refactor: test: wrapper for enable_ust_lttng_event
[lttng-tools.git] / tests / regression / tools / snapshots / ust_test
index e727aa6349f5075fcf04531374af08b9092c9571..61c364f68319bb480b784681d815abbbe7bc63f2 100755 (executable)
@@ -27,6 +27,7 @@ TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 NR_ITER=2000000
 NR_USEC_WAIT=100
+APPS_PID=
 
 NUM_TESTS=76
 
@@ -48,11 +49,13 @@ NUM_TESTS=$(($NUM_TESTS + ($NR_SNAPSHOT * 2)))
 
 function start_test_app()
 {
-       local tmp_file="/tmp/lttng_test_ust.42.file"
+       local tmp_file=$(mktemp -u)
 
        # Start application with a temporary file.
        $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $tmp_file &
-       ok $? "Start application to trace"
+       ret=$?
+       APPS_PID="${APPS_PID} ${!}"
+       ok $ret "Start application to trace"
 
        # Wait for the application file to appear indicating that at least one
        # tracepoint has been fired.
@@ -63,11 +66,14 @@ function start_test_app()
        rm -f $tmp_file
 }
 
-function kill_test_app()
+function stop_test_apps()
 {
-       diag "Killing $TESTAPP_NAME"
-       PID_APP=`pidof $TESTAPP_NAME`
-       kill $PID_APP >/dev/null 2>&1
+       diag "Stopping $TESTAPP_NAME"
+       for p in ${APPS_PID}; do
+               kill ${p}
+               wait ${p} 2>/dev/null
+       done
+       APPS_PID=
 }
 
 function snapshot_add_output ()
@@ -124,7 +130,7 @@ function test_ust_list_output ()
        diag "Test UST snapshot output listing"
        create_lttng_session_no_output $SESSION_NAME
        enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
 
        start_lttng_tracing $SESSION_NAME
 
@@ -152,7 +158,7 @@ function test_ust_local_snapshot ()
        diag "Test local UST snapshots"
        create_lttng_session_no_output $SESSION_NAME
        enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
        start_lttng_tracing $SESSION_NAME
        lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
 
@@ -168,11 +174,9 @@ function test_ust_local_snapshot ()
        if [ $? -eq 0 ]; then
                # Only delete if successful
                rm -rf $TRACE_PATH
-       else
-               break
        fi
 
-       kill_test_app
+       stop_test_apps
 }
 
 function test_ust_local_snapshot_max_size ()
@@ -188,7 +192,7 @@ function test_ust_local_snapshot_max_size ()
 
        enable_mmap_overwrite_subbuf_ust_channel $SESSION_NAME $CHANNEL_NAME $subbuf_size
 
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
        start_lttng_tracing $SESSION_NAME
 
        snapshot_add_output $SESSION_NAME "file://$TRACE_PATH" "" $max_size
@@ -220,7 +224,7 @@ function test_ust_local_snapshot_max_size ()
                rm -rf $TRACE_PATH
        fi
 
-       kill_test_app
+       stop_test_apps
 }
 
 function test_ust_local_snapshot_large_metadata ()
@@ -233,7 +237,7 @@ function test_ust_local_snapshot_large_metadata ()
        diag "Test local UST snapshots with > 4kB metadata"
        create_lttng_session_no_output $SESSION_NAME
        enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
-       enable_ust_lttng_event $SESSION_NAME $LM_EVENT $CHANNEL_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME $LM_EVENT $CHANNEL_NAME
        start_lttng_tracing $SESSION_NAME
        lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
        $LM_BIN 1 1
@@ -247,8 +251,6 @@ function test_ust_local_snapshot_large_metadata ()
        if [ $? -eq 0 ]; then
                # Only delete if successful
                rm -rf $TRACE_PATH
-       else
-               break
        fi
 }
 
@@ -266,7 +268,7 @@ function test_ust_per_uid_local_snapshot ()
        diag "Test local UST snapshots"
        create_lttng_session_no_output $SESSION_NAME
        enable_channel_per_uid_mmap_overwrite $SESSION_NAME $CHANNEL_NAME
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
        start_lttng_tracing $SESSION_NAME
        lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
 
@@ -282,11 +284,9 @@ function test_ust_per_uid_local_snapshot ()
        if [ $? -eq 0 ]; then
                # Only delete if successful
                rm -rf $TRACE_PATH
-       else
-               break
        fi
 
-       kill_test_app
+       stop_test_apps
 }
 
 function test_ust_per_uid_local_snapshot_post_mortem ()
@@ -294,13 +294,13 @@ function test_ust_per_uid_local_snapshot_post_mortem ()
        diag "Test local UST snapshots post-mortem"
        create_lttng_session_no_output $SESSION_NAME
        enable_channel_per_uid_mmap_overwrite $SESSION_NAME $CHANNEL_NAME
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
        start_lttng_tracing $SESSION_NAME
        lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
 
        # Returns once the application has at least fired ONE tracepoint.
        start_test_app
-       kill_test_app
+       stop_test_apps
 
        lttng_snapshot_record $SESSION_NAME
        stop_lttng_tracing $SESSION_NAME
@@ -311,8 +311,6 @@ function test_ust_per_uid_local_snapshot_post_mortem ()
        if [ $? -eq 0 ]; then
                # Only delete if successful
                rm -rf $TRACE_PATH
-       else
-               break
        fi
 }
 
@@ -321,7 +319,7 @@ function test_ust_local_snapshots ()
        diag "Test $NR_SNAPSHOT local UST snapshots"
        create_lttng_session_no_output $SESSION_NAME
        enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
        start_lttng_tracing $SESSION_NAME
        lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
 
@@ -337,14 +335,12 @@ function test_ust_local_snapshots ()
                if [ $? -eq 0 ]; then
                        # Only delete if successful
                        rm -rf $TRACE_PATH
-               else
-                       break
                fi
        done
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       kill_test_app
+       stop_test_apps
 }
 
 plan_tests $NUM_TESTS
This page took 0.027805 seconds and 5 git commands to generate.