Test: mi for clear command
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 11 Feb 2019 16:45:27 +0000 (11:45 -0500)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 18 Feb 2019 19:25:02 +0000 (14:25 -0500)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
tests/regression/tools/mi/test_mi
tests/utils/utils.sh

index 5ae71c745f0911ef59155d1f7bf48462f4250313..e04db27afdb5ea092c7379e73c5aab63174070a0 100755 (executable)
@@ -57,7 +57,7 @@ DEVNULL=/dev/null 2>&1
 
 DIR=$(readlink -f $TESTDIR)
 
-NUM_TESTS=230
+NUM_TESTS=246
 
 source $TESTDIR/utils/utils.sh
 
@@ -889,6 +889,56 @@ function test_add_context_list()
        ok $? "Mi test: context listing validation"
 }
 
+function test_clear_session ()
+{
+       # Since the session are not started there is no real clear done.
+       # We are testing the MI output only here.
+       local session_name=(
+                       "testSession1"
+                       "testSession2"
+                       "testSession3")
+
+       OUTPUT_FILE="clear_session.xml"
+
+       #Test build up
+       OUTPUT_DEST=$DEVNULL
+       for (( i = 0; i < 3; i++ )); do
+               create_lttng_session_ok ${session_name[$i]} $OUTPUT_DIR
+       done
+
+       OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
+       lttng_clear_session_ok  ${session_name[0]}
+       $XML_VALIDATE $OUTPUT_DEST
+       ok $? "MI test: clear session ${session_name[0]} xsd validation"
+
+       #Verify that we cleared the good session
+       extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
+       test "$result" = "${session_name[0]}"
+       ok $? "Mi test: cleared session: $result expected: ${session_name[0]}"
+
+       #Destroy all and count:should be 3
+       lttng_clear_all
+       $XML_VALIDATE $OUTPUT_DEST
+       ok $? "MI test: clear all session xsd validation"
+
+       #Verify that we cleared 3 sessions
+       extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
+       num=$(echo "$result" | wc -l)
+       test "$num" -eq "3"
+       ok $? "Mi test: $num / 3 sessions discovered"
+
+       destroy_lttng_sessions
+
+       #Verify that if no session is present command fail and mi report it.
+       lttng_clear_session_fail ${session_name[0]}
+       $XML_VALIDATE $OUTPUT_DEST
+       ok $? "MI test: failing clear session ${session_name[0]} xsd validation"
+       extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
+       test "$result" = "false"
+       ok $? "Mi test: clear command on ${session_name[0]} failed as expected"
+
+}
+
 start_lttng_sessiond $SESSIOND_LOAD_DIR
 TESTS=(
        test_version
@@ -906,6 +956,7 @@ TESTS=(
        test_track_untrack
        test_list_session_long_path
        test_add_context_list
+       test_clear_session
 )
 
 
index 24256e436681a1fda2d502661c1e381517135b91..5a929020ed6d23e90c4f0cea0f4b9d03e00b62fc 100644 (file)
@@ -1793,3 +1793,9 @@ function lttng_clear_session_fail ()
 {
        lttng_clear_session 1 $@
 }
+
+function lttng_clear_all ()
+{
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN clear --all 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ok $? "Clear all lttng sessions"
+}
This page took 0.038001 seconds and 5 git commands to generate.