From 5ee26199ebe087bb725f096a932a22b0c73f2bc0 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Mon, 11 Feb 2019 11:45:27 -0500 Subject: [PATCH] tests: mi for clear command MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Rajotte Change-Id: I769825ce10ce08cc1ae127821982d7ec3b1448ca Signed-off-by: Jérémie Galarneau --- tests/regression/tools/mi/test_mi | 53 ++++++++++++++++++++++++++++++- tests/utils/utils.sh | 6 ++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/tests/regression/tools/mi/test_mi b/tests/regression/tools/mi/test_mi index 124deae01..8ab91cfef 100755 --- a/tests/regression/tools/mi/test_mi +++ b/tests/regression/tools/mi/test_mi @@ -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 ) diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index df2671eb6..1525b7b2a 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -1996,3 +1996,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" +} -- 2.34.1