mi: support "add-context --list"
[lttng-tools.git] / tests / utils / utils.sh
index 9980e8538a124006a035403ef423fbe9c9c453ae..7181e3b88b8e60684a869dd81359dd5786a28981 100644 (file)
@@ -125,6 +125,16 @@ function conf_proc_count()
        echo
 }
 
+# Check if base lttng-modules are present.
+# Bail out on failure
+function validate_lttng_modules_present ()
+{
+       modprobe -n lttng-tracer 2>/dev/null
+       if [ $? -ne 0  ]; then
+               BAIL_OUT "LTTng modules not detected."
+       fi
+}
+
 function enable_kernel_lttng_event
 {
        local withtap="$1"
@@ -713,6 +723,15 @@ function create_lttng_session_no_output ()
        ok $? "Create session $sess_name in no-output mode"
 }
 
+function create_lttng_session_uri () {
+       local sess_name=$1
+       local uri=$2
+       local opts="${@:3}"
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -U $uri $opts 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ok $? "Create session $sess_name with uri:$uri and opts: $opts"
+}
+
 function create_lttng_session ()
 {
        local withtap=$1
@@ -1318,6 +1337,13 @@ function lttng_untrack_kernel_all_ok()
        ok $? "Lttng untrack all pid on the kernel domain"
 }
 
+function lttng_add_context_list()
+{
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context --list 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ret=$?
+       ok $ret "Context listing"
+}
+
 function add_context_lttng()
 {
        local expected_to_fail="$1"
@@ -1579,6 +1605,31 @@ function regenerate_statedump_fail ()
        regenerate_statedump 1 "$@"
 }
 
+function rotate_session ()
+{
+       local expected_to_fail=$1
+       local sess_name=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN rotate $sess_name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ret=$?
+       if [[ $expected_to_fail -eq "1" ]]; then
+               test "$ret" -ne "0"
+               ok $? "Expected fail on rotate session $sess_name"
+       else
+               ok $ret "Rotate session $sess_name"
+       fi
+}
+
+function rotate_session_ok ()
+{
+       rotate_session 0 "$@"
+}
+
+function rotate_session_fail ()
+{
+       rotate_session 1 "$@"
+}
+
 function destructive_tests_enabled ()
 {
        if [ ${LTTNG_ENABLE_DESTRUCTIVE_TESTS} = "will-break-my-system" ]; then
@@ -1587,3 +1638,55 @@ function destructive_tests_enabled ()
                return 1
        fi
 }
+
+function lttng_enable_rotation_timer ()
+{
+       local expected_to_fail=$1
+       local sess_name=$2
+       local period=$3
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-rotation -s $sess_name --timer $period 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ret=$?
+       if [[ $expected_to_fail -eq "1" ]]; then
+               test "$ret" -ne "0"
+               ok $? "Expected fail on rotate session $sess_name"
+       else
+               ok $ret "Rotate session $sess_name"
+       fi
+}
+
+function lttng_enable_rotation_timer_ok ()
+{
+       lttng_enable_rotation_timer 0 $@
+}
+
+function lttng_enable_rotation_timer_fail ()
+{
+       lttng_enable_rotation_timer 1 $@
+}
+
+function lttng_enable_rotation_size ()
+{
+       local expected_to_fail=$1
+       local sess_name=$2
+       local size=$3
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-rotation -s $sess_name --size $size 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ret=$?
+       if [[ $expected_to_fail -eq "1" ]]; then
+               test "$ret" -ne "0"
+               ok $? "Expected fail on rotate session $sess_name"
+       else
+               ok $ret "Rotate session $sess_name"
+       fi
+}
+
+function lttng_enable_rotation_size_ok ()
+{
+       lttng_enable_rotation_size 0 $@
+}
+
+function lttng_enable_rotation_size_fail ()
+{
+       lttng_enable_rotation_size 1 $@
+}
This page took 0.024647 seconds and 4 git commands to generate.