Refactor: test: wrapper for destroy_lttng_session
[lttng-tools.git] / tests / utils / utils.sh
index fe75461fc8603aafce928db1b292ae2cd2a3ea85..454627eaae3ad6115b598f3067d1f81410899631 100644 (file)
@@ -27,6 +27,11 @@ KERNEL_MAJOR_VERSION=2
 KERNEL_MINOR_VERSION=6
 KERNEL_PATCHLEVEL_VERSION=27
 
+# We set the default UST register timeout to "wait forever", so that
+# basic tests don't have to worry about hitting timeouts on busy
+# systems. Specialized tests should test those corner-cases.
+export LTTNG_UST_REGISTER_TIMEOUT=-1
+
 source $TESTDIR/utils/tap/tap.sh
 
 function print_ok ()
@@ -311,7 +316,7 @@ function start_lttng_sessiond()
                else
                        $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
                fi
-               #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1 &
+               #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1
                status=$?
                ok $status "Start session daemon"
        fi
@@ -363,13 +368,13 @@ function create_lttng_session_no_output ()
 
 function create_lttng_session ()
 {
-       local sess_name=$1
-       local trace_path=$2
-       local expected_to_fail=$3
+       local expected_to_fail=$1
+       local sess_name=$2
+       local trace_path=$3
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path > $OUTPUT_DEST
        ret=$?
-       if [[ $expected_to_fail ]]; then
+       if [[ $expected_to_fail -eq "1" ]]; then
                test "$ret" -ne "0"
                ok $? "Expected fail on session creation $sess_name in $trace_path"
        else
@@ -377,15 +382,26 @@ function create_lttng_session ()
        fi
 }
 
-function enable_ust_lttng_channel()
+function create_lttng_session_ok ()
 {
-       local sess_name=$1
-       local channel_name=$2
-       local expect_fail=$3
+       create_lttng_session 0 "$@"
+}
+
+function create_lttng_session_fail ()
+{
+       create_lttng_session 1 "$@"
+}
+
+
+function enable_ust_lttng_channel ()
+{
+       local expect_fail=$1
+       local sess_name=$2
+       local channel_name=$3
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -u $channel_name -s $sess_name >$OUTPUT_DEST
        ret=$?
-       if [[ $expect_fail ]]; then
+       if [[ $expect_fail -eq "1" ]]; then
                test "$ret" -ne "0"
                ok $? "Expected fail on ust channel creation $channel_name in $sess_name"
        else
@@ -393,6 +409,16 @@ function enable_ust_lttng_channel()
        fi
 }
 
+function enable_ust_lttng_channel_ok ()
+{
+       enable_ust_lttng_channel 0 "$@"
+}
+
+function enable_ust_lttng_channel_fail ()
+{
+       enable_ust_lttng_channel 1 "$@"
+}
+
 function disable_ust_lttng_channel()
 {
        local sess_name=$1
@@ -422,10 +448,10 @@ function enable_lttng_mmap_overwrite_ust_channel()
 
 function enable_ust_lttng_event ()
 {
-       local sess_name=$1
-       local event_name="$2"
-       local channel_name=$3
-       local expected_to_fail=$4
+       local expected_to_fail=$1
+       local sess_name=$2
+       local event_name="$3"
+       local channel_name=$4
 
        if [ -z $channel_name ]; then
                # default channel if none specified
@@ -436,7 +462,7 @@ function enable_ust_lttng_event ()
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -u >$OUTPUT_DEST
        ret=$?
-       if [[ $expected_to_fail ]]; then
+       if [[ $expected_to_fail -eq "1" ]]; then
                test $ret -ne "0"
                ok $? "Enable ust event $event_name for session $session_name on channel $channel_name failed as expected"
        else
@@ -444,6 +470,16 @@ function enable_ust_lttng_event ()
        fi
 }
 
+function enable_ust_lttng_event_ok ()
+{
+       enable_ust_lttng_event 0 "$@"
+}
+
+function enable_ust_lttng_event_fail ()
+{
+       enable_ust_lttng_event 1 "$@"
+}
+
 function enable_jul_lttng_event()
 {
        sess_name=$1
@@ -625,12 +661,12 @@ function disable_python_lttng_event ()
 
 function start_lttng_tracing ()
 {
-       local sess_name=$1
-       local expected_to_fail=$2
+       local expected_to_fail=$1
+       local sess_name=$2
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name >$OUTPUT_DEST
        ret=$?
-       if [[ $expected_to_fail ]]; then
+       if [[ $expected_to_fail -eq "1" ]]; then
                test "$ret" -ne "0"
                ok $? "Expected fail on start tracing for session: $sess_name"
        else
@@ -638,14 +674,24 @@ function start_lttng_tracing ()
        fi
 }
 
+function start_lttng_tracing_ok ()
+{
+       start_lttng_tracing 0 "$@"
+}
+
+function start_lttng_tracing_fail ()
+{
+       start_lttng_tracing 1 "$@"
+}
+
 function stop_lttng_tracing ()
 {
-       local sess_name=$1
-       local expected_to_fail=$2
+       local expected_to_fail=$1
+       local sess_name=$2
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name >$OUTPUT_DEST
        ret=$?
-       if [[ $expected_to_fail ]]; then
+       if [[ $expected_to_fail -eq "1" ]]; then
                test "$ret" -ne "0"
                ok $? "Expected fail on stop tracing for session: $sess_name"
        else
@@ -653,14 +699,24 @@ function stop_lttng_tracing ()
        fi
 }
 
+function stop_lttng_tracing_ok ()
+{
+       stop_lttng_tracing 0 "$@"
+}
+
+function stop_lttng_tracing_fail ()
+{
+       stop_lttng_tracing 1 "$@"
+}
+
 function destroy_lttng_session ()
 {
-       local sess_name=$1
-       local expected_to_fail=$2
+       local expected_to_fail=$1
+       local sess_name=$2
 
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name >$OUTPUT_DEST
        ret=$?
-       if [[ $expected_to_fail ]]; then
+       if [[ $expected_to_fail -eq "1" ]]; then
                test "$ret" -ne "0"
                ok $? "Expected fail on session deletion $sess_name"
        else
@@ -668,6 +724,18 @@ function destroy_lttng_session ()
        fi
 }
 
+function destroy_lttng_session_ok ()
+{
+       destroy_lttng_session 0 "$@"
+
+}
+
+function destroy_lttng_session_fail ()
+{
+       destroy_lttng_session 1 "$@"
+}
+
+
 function destroy_lttng_sessions ()
 {
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy --all >$OUTPUT_DEST
This page took 0.027203 seconds and 4 git commands to generate.