Tests: use functions from utils.sh
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 11 Sep 2015 14:46:05 +0000 (10:46 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 16 Sep 2015 22:38:45 +0000 (18:38 -0400)
v2: remove redundant information in success message.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/ust/test_event_basic
tests/utils/utils.sh

index 31931a977b094a7bb373dd3e7358f061460299cc..acc79e5320d262bcfc6bee2033f9569041542247 100755 (executable)
@@ -23,39 +23,11 @@ LTTNG_BIN="lttng"
 BIN_NAME="gen-ust-events"
 SESSION_NAME="valid_filter"
 EVENT_NAME="tp:tptest"
 BIN_NAME="gen-ust-events"
 SESSION_NAME="valid_filter"
 EVENT_NAME="tp:tptest"
-NUM_TESTS=25
-
-source $TESTDIR/utils/utils.sh
-
-function enable_ust_lttng_event_per_chan()
-{
-       sess_name="$1"
-       event_name="$2"
-       chan_name="$3"
-
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
-       ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
-}
 
 
-function disable_ust_lttng_event_per_chan()
-{
-       sess_name="$1"
-       event_name="$2"
-       chan_name="$3"
-
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
-       ok $? "Disable event $event_name for session $sess_name in channel $chan_name"
-}
 
 
-function add_ust_lttng_context()
-{
-       sess_name="$1"
-       chan_name="$2"
-       type="$3"
+NUM_TESTS=25
 
 
-       $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name -t $type -u >/dev/null 2>&1
-       ok $? "Add context $type for session $sess_name in channel $chan_name"
-}
+source $TESTDIR/utils/utils.sh
 
 function test_event_basic()
 {
 
 function test_event_basic()
 {
@@ -74,21 +46,21 @@ function test_event_basic()
        enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
        enable_ust_lttng_channel_ok $SESSION_NAME2 $CHAN_NAME2
 
        enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
        enable_ust_lttng_channel_ok $SESSION_NAME2 $CHAN_NAME2
 
-       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
-       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME2 $CHAN_NAME
-       enable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHAN_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME2 $CHAN_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
 
 
-       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "vpid"
-       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "vtid"
-       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "pthread_id"
-       add_ust_lttng_context $SESSION_NAME $CHAN_NAME "procname"
-       add_ust_lttng_context $SESSION_NAME2 $CHAN_NAME2 "procname"
+       add_context_ust_ok $SESSION_NAME $CHAN_NAME "vpid"
+       add_context_ust_ok $SESSION_NAME $CHAN_NAME "vtid"
+       add_context_ust_ok $SESSION_NAME $CHAN_NAME "pthread_id"
+       add_context_ust_ok $SESSION_NAME $CHAN_NAME "procname"
+       add_context_ust_ok $SESSION_NAME2 $CHAN_NAME2 "procname"
 
 
-       disable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
-       disable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
+       disable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHAN_NAME
+       disable_ust_lttng_event $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
 
 
-       enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
-       enable_ust_lttng_event_per_chan $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHAN_NAME
+       enable_ust_lttng_event_ok $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
 
        start_lttng_tracing_ok
        stop_lttng_tracing_ok
 
        start_lttng_tracing_ok
        stop_lttng_tracing_ok
index a0c9940ac90bcff283863f286b1fce03fa326866..5ffe6eb47ad8da6836e3e183356cb09066360033 100644 (file)
@@ -1017,6 +1017,44 @@ function lttng_untrack_fail()
        lttng_untrack 1 "$@"
 }
 
        lttng_untrack 1 "$@"
 }
 
+function add_context_lttng()
+{
+       local expected_to_fail="$1"
+       local domain="$2"
+       local session_name="$3"
+       local channel_name="$4"
+       local type="$5"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $session_name -c $channel_name -t $type $domain  1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ret=$?
+       if [[ $expected_to_fail -eq "1" ]]; then
+               test $ret -ne "0"
+               ok $? "Add context command failed as expected for type: $type"
+       else
+               ok $ret "Add context command for type: $type"
+       fi
+}
+
+function add_context_ust_ok()
+{
+       add_context_lttng 0 -u "$@"
+}
+
+function add_context_ust_fail()
+{
+       add_context_lttng 1 -u "$@"
+}
+
+function add_context_kernel_ok()
+{
+       add_context_lttng 0 -k "$@"
+}
+
+function add_context_kernel_fail()
+{
+       add_context_lttng 1 -k "$@"
+}
+
 function trace_matches ()
 {
        local event_name=$1
 function trace_matches ()
 {
        local event_name=$1
This page took 0.029426 seconds and 5 git commands to generate.