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 18d8a46c1b7ea213fe8299baabdffaf3c48b1b72..fe4550bf3db4e4f41638689996655006fe3f556c 100755 (executable)
@@ -41,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"
 }
 
@@ -71,6 +80,24 @@ function wait_apps
        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
 
@@ -79,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
 
        $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() {
@@ -105,27 +135,18 @@ test_before_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
 
        # 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
@@ -140,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
 
        $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() {
@@ -166,26 +190,17 @@ test_before_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
 
        # 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.034388 seconds and 4 git commands to generate.