Fix: tests: provide channel name when a non-default channel exists: per-pid
[lttng-tools.git] / tests / regression / ust / periodical-metadata-flush / test_periodical_metadata_flush
index 2d984d522ada32914cd7cedfda385fa434cf5bf3..fe4550bf3db4e4f41638689996655006fe3f556c 100755 (executable)
@@ -19,15 +19,19 @@ TEST_DESC="UST tracer - Tracing with per UID buffers and periodical flush"
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../../..
 NR_ITER=100
+NR_USEC_WAIT=100000
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 SESSION_NAME="periodical-flush"
-EVENT_NAME="ust_gen_nevents:tptest"
+EVENT_NAME="tp:tptest"
 BIN_NAME="gen-nevents"
 NUM_TESTS=38
 
 source $TESTDIR/utils/utils.sh
 
-if [ ! -x "$CURDIR/gen-nevents" ]; then
-       BAIL_OUT "No UST nevents binary detected."
+if [ ! -x "$TESTAPP_BIN" ]; then
+       BAIL_OUT "No UST events binary detected."
 fi
 
 # MUST set TESTDIR before calling those functions
@@ -37,7 +41,16 @@ function enable_channel_per_uid()
        local sess_name=$1
        local channel_name=$2
 
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name >/dev/null 2>&1
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name --switch-timer 1000000 >/dev/null 2>&1
+       ok $? "Enable channel $channel_name per UID for session $sess_name"
+}
+
+function enable_channel_per_pid()
+{
+       local sess_name=$1
+       local channel_name=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name --switch-timer 1000000 >/dev/null 2>&1
        ok $? "Enable channel $channel_name per UID for session $sess_name"
 }
 
@@ -62,11 +75,29 @@ function enable_metadata_per_pid()
 function wait_apps
 {
        diag "Waiting for applications to end..."
-       while [ -n "$(pidof $BIN_NAME)" ]; do
+       while [ -n "$(pidof $TESTAPP_NAME)" ]; do
                sleep 1
        done
 }
 
+function validate_trace()
+{
+       local out
+
+       out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
+       if [ $out -eq 0 ]; then
+               fail "Trace validation"
+               diag "No event(s) found. We are supposed to have at least one."
+               out=1
+       else
+               pass "Trace validation"
+               diag "Found $out event(s). Coherent."
+               out=0
+       fi
+
+       return $out
+}
+
 test_after_app_pid() {
        local out
 
@@ -75,19 +106,22 @@ test_after_app_pid() {
        # BEFORE application is spawned
        create_lttng_session $SESSION_NAME $TRACE_PATH
        enable_metadata_per_pid $SESSION_NAME
-       enable_ust_lttng_channel $SESSION_NAME "channel0"
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+       enable_channel_per_pid $SESSION_NAME "channel0"
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
        start_lttng_tracing $SESSION_NAME
 
-       ./$CURDIR/$BIN_NAME $NR_ITER
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
        ok $? "Start application to trace"
 
+       # At least hit one event
+       sleep 2
+       validate_trace
+       out=$?
+
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
-
-       return $?
+       return $out
 }
 
 test_before_app_pid() {
@@ -95,33 +129,24 @@ test_before_app_pid() {
 
        diag "Start application BEFORE tracing is started"
 
-       ./$CURDIR/$BIN_NAME $NR_ITER &
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
        ok $? "Start application to trace"
 
        # BEFORE application is spawned
        create_lttng_session $SESSION_NAME $TRACE_PATH
        enable_metadata_per_pid $SESSION_NAME
-       enable_ust_lttng_channel $SESSION_NAME "channel0"
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+       enable_channel_per_pid $SESSION_NAME "channel0"
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
        start_lttng_tracing $SESSION_NAME
 
        # At least hit one event
        sleep 2
+       validate_trace
+       out=$?
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
-       if [ $out -eq 0 ]; then
-               fail "Trace validation"
-               diag "No event(s) found. We are supposed to have at least one."
-               out=1
-       else
-               pass "Trace validation"
-               diag "Found $out event(s). Coherent."
-               out=0
-       fi
-
        wait_apps
 
        return $out
@@ -136,18 +161,21 @@ test_after_app_uid() {
        create_lttng_session $SESSION_NAME $TRACE_PATH
        enable_metadata_per_uid $SESSION_NAME
        enable_channel_per_uid $SESSION_NAME "channel0"
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
        start_lttng_tracing $SESSION_NAME
 
-       ./$CURDIR/$BIN_NAME $NR_ITER
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT
        ok $? "Start application to trace"
 
+       # At least hit one event
+       sleep 2
+       validate_trace
+       out=$?
+
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
-
-       return $?
+       return $out
 }
 
 test_before_app_uid() {
@@ -155,33 +183,24 @@ test_before_app_uid() {
 
        diag "Start application BEFORE tracing is started"
 
-       ./$CURDIR/$BIN_NAME $NR_ITER &
+       $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
        ok $? "Start application to trace"
 
        # BEFORE application is spawned
        create_lttng_session $SESSION_NAME $TRACE_PATH
        enable_metadata_per_uid $SESSION_NAME
        enable_channel_per_uid $SESSION_NAME "channel0"
-       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0"
        start_lttng_tracing $SESSION_NAME
 
        # At least hit one event
        sleep 2
+       validate_trace
+       out=$?
 
        stop_lttng_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
-       out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
-       if [ $out -eq 0 ]; then
-               fail "Trace validation"
-               diag "No event(s) found. We are supposed to have at least one."
-               out=1
-       else
-               pass "Trace validation"
-               diag "Found $out event(s). Coherent."
-               out=0
-       fi
-
        wait_apps
 
        return $out
This page took 0.035973 seconds and 4 git commands to generate.