3 # Copyright (C) - 2014 Jonathan Rajotte <jonathan.r.julien@gmail.com>
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 TEST_DESC
="Machine interface testing"
21 TESTDIR
=$CURDIR/..
/..
/..
/
22 XSD_PATH
=$TESTDIR/..
/src
/common
/mi-lttng-3.0.xsd
24 #Test app for ust event
25 TESTAPP_PATH
="$TESTDIR/utils/testapp"
26 TESTAPP_NAME
="gen-ust-events"
27 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
32 OUTPUT_DIR
=$
(mktemp
-d)
33 SESSIOND_LOAD_DIR
=$
(mktemp
-d)
34 OUTPUT_FILE
="default.xml"
36 #Path to custom xml utilities
37 XML_VALIDATE
="$CURDIR/validate_xml $XSD_PATH"
38 XML_EXTRACT
="$CURDIR/extract_xml"
39 XML_NODE_CHECK
="$CURDIR/extract_xml -e"
41 XPATH_CMD_OUTPUT
="//lttng:command/lttng:output"
42 XPATH_COMMAND_SUCCESS
="/lttng:command/lttng:success/text()"
43 XPATH_SESSION
="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session"
44 XPATH_ENABLE_CHANNEL_NAME
="$XPATH_CMD_OUTPUT/lttng:channels/lttng:channel/lttng:name/text()"
45 XPATH_ENABLE_EVENT_SUCCESS
="$XPATH_CMD_OUTPUT/lttng:events/lttng:event/lttng:success/text()"
46 XPATH_DISABLE_EVENT_SUCCESS
="$XPATH_CMD_OUTPUT/lttng:channel/lttng:events/lttng:event/lttng:success/text()"
47 XPATH_LIST_DOMAIN
="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain"
48 XPATH_LIST_CHANNEL
="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel"
49 XPATH_LIST_UST_EVENT
="$XPATH_CMD_OUTPUT/lttng:domains/lttng:domain[./lttng:type ='UST']/lttng:pids/lttng:pid/lttng:events/lttng:event"
50 XPATH_SNAPSHOT_ADD_SNAPSHOT
="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'add-output']/lttng:output"
51 XPATH_SNAPSHOT_LIST
="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'list-output']/lttng:output"
52 XPATH_SNAPSHOT_DEL
="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'del-output']/lttng:output"
53 XPATH_TRACK_UNTRACK_PID
="$XPATH_CMD_OUTPUT/lttng:targets/lttng:pid_target"
54 XPATH_PID_TRACKER
="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:pid_tracker"
56 DEVNULL
=/dev
/null
2>&1
58 DIR
=$
(readlink
-f $TESTDIR)
62 source $TESTDIR/utils
/utils.sh
64 #Overwrite the lttng_bin to get mi output
65 LTTNG_BIN
="lttng --mi xml"
67 #Global declaration for simplification
68 LTTNG
=$TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN
70 #Overwrite the default output for utils.sh command
72 #MUST set TESTDIR before calling those functions
75 print_test_banner
"$TEST_DESC"
77 function extract_xml
()
83 output
=$
($XML_EXTRACT $xml "$xpath")
84 ok $?
"Extraction of xpath $xpath"
85 eval $__result="'$output'"
88 function node_check_xml
()
94 output
=$
($XML_NODE_CHECK $xml "$xpath")
95 ok $?
"Check of node existence with xpath $xpath"
96 eval $__result="'$output'"
99 # Arg1 is path to xml file
101 # is true if we expected the success element to be false
105 function is_command_success
()
108 local expect_false
=$2
110 local xpath
=$XPATH_COMMAND_SUCCESS
113 #Extract the success element
115 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
116 if [[ $expect_false = "true" ]]; then
117 if [[ $result ]]; then
118 pass
"Mi test: $xml command failed as expected"
120 fail
"Mi test: $xml command did not fail as expected"
123 if [[ $result ]]; then
124 pass
"Mi test: $xml command success"
126 fail
"Mi test: $xml command failed"
131 function mi_print_version
()
136 $LTTNG version
$opt > $output_path
137 ok $?
"MI test: Lttng version"
141 function test_version
()
143 OUTPUT_FILE
="version.xml"
144 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
145 mi_print_version
$OUTPUT_DEST
146 $XML_VALIDATE $OUTPUT_DEST
147 ok $?
"MI test: Version xsd validation"
150 function test_create_session
()
152 local session_name
="testSession"
154 OUTPUT_FILE
="create_session.xml"
155 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
156 create_lttng_session_ok
$session_name $OUTPUT_DIR
157 $XML_VALIDATE $OUTPUT_DEST
158 ok $?
"MI test: create session xsd validation"
160 #try to recreate a session. Expecting it to fail
161 create_lttng_session_fail
$session_name $OUTPUT_DIR
162 $XML_VALIDATE $OUTPUT_DEST
163 ok $?
"MI test: expecting fail create session xsd validation"
164 is_command_success
$OUTPUT_DEST true
167 destroy_lttng_session_ok
$session_name
170 function test_destroy_session
()
177 OUTPUT_FILE
="destroy_session.xml"
181 for (( i
= 0; i
< 3; i
++ )); do
182 create_lttng_session_ok
${session_name[$i]} $OUTPUT_DIR
185 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
186 destroy_lttng_session_ok
${session_name[0]}
187 $XML_VALIDATE $OUTPUT_DEST
188 ok $?
"MI test: destroy session ${session_name[0]} xsd validation"
190 #Verify that we destroyed the good session
191 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
192 test "$result" = "${session_name[0]}"
193 ok $?
"Mi test: deleted session: $result expected: ${session_name[0]}"
195 #Destroy all and count:should be 2
196 destroy_lttng_sessions
197 $XML_VALIDATE $OUTPUT_DEST
198 ok $?
"MI test: destroy all session xsd validation"
200 #Verify that we destroyed 2 sessions
201 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
202 num
=$
(echo "$result" |
wc -l)
204 ok $?
"Mi test: $num / 2 sessions discovered"
206 #Verify that if no session is present command fail and mi report it.
207 destroy_lttng_session_fail
${session_name[0]}
208 $XML_VALIDATE $OUTPUT_DEST
209 ok $?
"MI test: failing destroy session ${session_name[0]} xsd validation"
210 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
211 test "$result" = "false"
212 ok $?
"Mi test: destroy command on ${session_name[0]} failed as expected"
216 function test_list_sessions
()
223 OUTPUT_FILE
="list_sessions.xml"
227 for (( i
= 0; i
< 3; i
++ )); do
228 create_lttng_session_ok
${session_name[$i]} $OUTPUT_DIR
231 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
233 $XML_VALIDATE $OUTPUT_DEST
234 ok $?
"Mi test: list sessions xsd validation"
236 #We should have 3 session
237 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
238 num
=$
(echo "$result" |
wc -l)
240 ok $?
"Mi test: $num / 3 sessions discovered"
244 destroy_lttng_sessions
247 function test_list_session_long_path
()
249 local session_name
="session_long_path"
251 output_basedir
=$OUTPUT_DIR/$
(randstring
254 0)
252 mkdir
-p ${output_basedir}
254 OUTPUT_FILE
="list_sessions.xml"
258 create_lttng_session_ok
$session_name ${output_basedir}
260 OUTPUT_DEST
=${output_basedir}/$OUTPUT_FILE
262 $XML_VALIDATE $OUTPUT_DEST
263 ok $?
"Mi test: list session with long path xsd validation"
267 destroy_lttng_sessions
269 function test_ust_channel
()
271 local session_name
="testsession"
272 local channel_name
=("channelUst0"
276 OUTPUT_FILE
="ust_channel.xml"
280 create_lttng_session_ok
$session_name $OUTPUT_DIR
282 #Test the enable_channel command
283 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
284 enable_ust_lttng_channel_ok
$session_name ${channel_name[0]}
285 $XML_VALIDATE $OUTPUT_DEST
286 ok $?
"Mi test: enable ust channel xsd validation"
287 is_command_success
$OUTPUT_DEST false
289 #Expect the command to fail
290 enable_ust_lttng_channel_fail
$session_name ${channel_name[0]}
291 $XML_VALIDATE $OUTPUT_DEST
292 ok $?
"Mi test: fail enable ust channel xsd validation"
293 is_command_success
$OUTPUT_DEST true
295 #Create two ust channel to test multiple disable
296 for (( i
= 1; i
< 3; i
++ )); do
297 enable_ust_lttng_channel_ok
$session_name ${channel_name[$i]}
300 #Test the disable_channel command
301 disable_ust_lttng_channel
$session_name ${channel_name[0]}
302 $XML_VALIDATE $OUTPUT_DEST
303 ok $?
"Mi test: disable ust channel xsd validation"
304 is_command_success
$OUTPUT_DEST false
305 #Check that we delete the good channel
306 extract_xml
$OUTPUT_DEST $XPATH_ENABLE_CHANNEL_NAME result
307 test "$result" = "${channel_name[0]}"
308 ok $?
"MI test: ${channel_name[0]} disabled"
310 #Test multiple disable_channel;
311 disable_ust_lttng_channel
$session_name ${channel_name[1]},${channel_name[2]}
312 $XML_VALIDATE $OUTPUT_DEST
313 ok $?
"Mi test: multiple disable ust channel xsd validation"
314 is_command_success
$OUTPUT_DEST false
316 #Make sure we have two disabled channel
317 extract_xml
$OUTPUT_DEST $XPATH_ENABLE_CHANNEL_NAME result
318 local num
=$
(echo "$result" |
wc -l)
320 ok $?
"Mi test: disabled ust channel $num/2"
324 destroy_lttng_sessions
328 function test_ust_lttng_event
()
330 local session_name
="testSession"
331 local channel_name
="testChannel"
332 local event
=("ev1" "ev2" "ev3")
334 OUTPUT_FILE
="ust_event.xml"
338 create_lttng_session_ok
$session_name $OUTPUT_DIR
339 enable_ust_lttng_channel_ok
$session_name $channel_name
341 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
342 #Test the enable event for ust domain
343 enable_ust_lttng_event_ok
$session_name ${event[0]} $channel_name
344 $XML_VALIDATE $OUTPUT_DEST
345 ok $?
"Mi test: Enable_event for ust domain xsd validation"
346 is_command_success
$OUTPUT_DEST false
348 #Try to reenable an enabled event. Should fail
349 enable_ust_lttng_event_fail
$session_name ${event[0]} $channel_name
350 $XML_VALIDATE $OUTPUT_DEST
351 ok $?
"Mi test: Fail enable_event for ust domain xsd validation"
352 is_command_success
$OUTPUT_DEST true
354 #Enable multiple event including the last one command will fail
355 #But 2 events should success
357 #Nice little hack, create a string ev,ev,ev
358 #IFS stand for Internal field separator
359 #Event[*] print all the element inside the array with the IFS in between
360 concat_event
=$
( IFS
=$
','; echo "${event[*]}" )
362 enable_ust_lttng_event_fail
$session_name $concat_event $channel_name
363 $XML_VALIDATE $OUTPUT_DEST
364 ok $?
"Mi test: Multiple enable ust event with inside fail xsd validation"
366 #Check for 2 success = true and 1 success = false
367 extract_xml
$OUTPUT_DEST $XPATH_ENABLE_EVENT_SUCCESS result
368 num_ocur
=$
(grep -o "true" <<< "$result" |
wc -l)
369 test "$num_ocur" -eq "2"
370 ok $?
"Mi test: Enabled event on failing enable command $num_ocur_true/2"
372 extract_xml
$OUTPUT_DEST $XPATH_ENABLE_EVENT_SUCCESS result
373 num_ocur
=$
(grep -o "false" <<< "$result" |
wc -l)
374 test "$num_ocur" -eq "1"
375 ok $?
"Mi test: Enabled event on failing enable command $num_ocur_true/2"
378 disable_ust_lttng_event
$session_name ${event[0]} $channel_name
379 $XML_VALIDATE $OUTPUT_DEST
380 ok $?
"Mi test: Disable ust event xsd validation"
381 is_command_success
$OUTPUT_DEST false
383 #Disable the 3 event combined. Should pass
384 disable_ust_lttng_event
$session_name $concat_event $channel_name
385 $XML_VALIDATE $OUTPUT_DEST
386 ok $?
"Mi test: Disable multiple ust event xsd validation"
387 is_command_success
$OUTPUT_DEST false
389 #Make sure we have 3 inner success
390 extract_xml
$OUTPUT_DEST $XPATH_DISABLE_EVENT_SUCCESS result
391 num_ocur
=$
(grep -o "true" <<< "$result" |
wc -l)
392 test "$num_ocur" -eq "3"
393 ok $?
"Mi test: Disable multiple ust event success $num_ocur/3"
397 destroy_lttng_sessions
400 function test_list_channel
()
402 local session_name
="testSession"
403 local channel_name
="testChannel"
404 local event
=("ev1" "ev2" "ev3")
406 OUTPUT_FILE
="list_channel.xml"
410 create_lttng_session_ok
$session_name $OUTPUT_DIR
411 enable_ust_lttng_channel_ok
$session_name $channel_name
413 #Enable ust and jul events
414 concat_event
=$
( IFS
=$
','; echo "${event[*]}" )
415 enable_ust_lttng_event_ok
$session_name $concat_event $channel_name
418 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
419 list_lttng_with_opts
"$session_name -c $channel_name"
420 $XML_VALIDATE $OUTPUT_DEST
421 ok $?
"Mi test: list channel xsd validation"
423 #Expect 1 domain: UST
424 extract_xml
$OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result
425 num
=$
(echo "$result" |
wc -l)
427 ok $?
"Mi test: $num / 1 domains discovered"
429 #Expect 1 channel: test
430 extract_xml
$OUTPUT_DEST $XPATH_LIST_CHANNEL"/lttng:name/text()" result
431 num
=$
(echo "$result" |
wc -l)
433 ok $?
"Mi test: $num / 1 channel discovered"
435 test "$result" = "$channel_name"
436 ok $?
"Mi test: expected channel: $channel_name found: $result"
438 #Add a channel and make sure we have 2 channel now
440 enable_ust_lttng_channel_ok
$session_name $channel_name"a"
444 destroy_lttng_sessions
447 function test_list_domain
()
449 local session_name
="testSession"
450 local channel_name
="testChannel"
451 local event
=("ev1" "ev2" "ev3")
453 OUTPUT_FILE
="list_domain.xml"
457 create_lttng_session_ok
$session_name $OUTPUT_DIR
458 enable_ust_lttng_channel_ok
$session_name $channel_name
460 #Enable ust and jul events
461 concat_event
=$
( IFS
=$
','; echo "${event[*]}" )
462 enable_ust_lttng_event_ok
$session_name $concat_event $channel_name
463 enable_jul_lttng_event
$session_name $concat_event $channel_name
466 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
467 list_lttng_with_opts
"$session_name -d"
468 $XML_VALIDATE $OUTPUT_DEST
469 ok $?
"Mi test: list domain xsd validation"
471 #Expect 2 domain: Jul and UST
472 extract_xml
$OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result
473 num
=$
(echo "$result" |
wc -l)
475 ok $?
"Mi test: $num / 2 domains discovered"
477 #Test for valid value
478 if [[ "$result" = *"JUL"* ]]; then
479 pass
"Mi test: domains Jul is present"
481 fail
"Mi test: domains Jul is absent"
484 if [[ "$result" = *"UST"* ]]; then
485 pass
"Mi test: domains UST is present"
487 fail
"Mi test: domains UST is absent"
492 destroy_lttng_sessions
495 function test_list_session
()
497 local session_name
="testSession"
498 local channel_name
="testChannel"
499 local event
=("ev1" "ev2" "ev3")
501 OUTPUT_FILE
="list_session.xml"
505 create_lttng_session_ok
$session_name $OUTPUT_DIR
506 enable_ust_lttng_channel_ok
$session_name $channel_name
508 #Enable ust and jul events
509 concat_event
=$
( IFS
=$
','; echo "${event[*]}" )
510 enable_ust_lttng_event_ok
$session_name $concat_event $channel_name
511 enable_jul_lttng_event
$session_name $concat_event $channel_name
514 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
515 list_lttng_with_opts
$session_name
516 $XML_VALIDATE $OUTPUT_DEST
517 ok $?
"Mi test: list session xsd validation"
519 #Expect 2 domain: Jul and UST
520 extract_xml
$OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result
521 num
=$
(echo "$result" |
wc -l)
523 ok $?
"Mi test: $num / 2 domains discovered"
525 #Expect 2 channel: test and lttng_jul_event
526 extract_xml
$OUTPUT_DEST $XPATH_LIST_CHANNEL"/lttng:name/text()" result
527 num
=$
(echo "$result" |
wc -l)
529 ok $?
"Mi test: $num / 2 channel discovered"
533 destroy_lttng_sessions
536 function test_list_ust_event
()
538 local file_sync_after_first
=$
(mktemp
-u)
539 local file_sync_before_last
=$
(mktemp
-u)
541 OUTPUT_FILE
="list_ust_event.xml"
544 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
547 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} & 2>/dev
/null
549 while [ ! -f "${file_sync_after_first}" ]; do
553 list_lttng_with_opts
"-u -f"
555 touch ${file_sync_before_last}
557 $XML_VALIDATE $OUTPUT_DEST
558 ok $?
"Mi test: list ust event xsd validation"
561 extract_xml
$OUTPUT_DEST "$XPATH_LIST_UST_EVENT""/lttng:name/text()" result
562 num
=$
(echo "$result" |
wc -l)
564 #Since the number of events is prone to change we only look for >= from a
565 #base number. An alternative would be to look for each events but this
566 #is complicated for nothing.
568 ok $?
"Mi test: $num / 5 ust events discovered"
570 #Extract field from tp:tptest event. Expect >= to 12 because number of
571 #field is prone to change.
572 extract_xml
$OUTPUT_DEST "$XPATH_LIST_UST_EVENT""[./lttng:name = 'tp:tptest']/lttng:event_fields/lttng:event_field/lttng:name/text()" result
573 num
=$
(echo "$result" |
wc -l)
575 ok $?
"Mi test: $num / 12 ust event fields discovered"
577 #Wait for all background processes
580 rm -f ${file_sync_after_first}
581 rm -f ${file_sync_before_last}
584 function test_start_stop
() {
585 local session_name
="testStartStopSession"
586 local channel_name
="startStopChannel"
588 OUTPUT_FILE
="list_start_stop.xml"
592 create_lttng_session_ok
$session_name $OUTPUT_DIR
595 #No channel enable start command should return element success false
596 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
597 start_lttng_tracing_fail
$session_name
598 $XML_VALIDATE $OUTPUT_DEST
599 ok $?
"Mi test: failed start xsd validation"
601 #Expect a false element
602 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
603 test "$result" = "false"
604 ok $?
"Mi test: mi report failure on start command as expected"
606 #Enable a channel to test success
608 enable_ust_lttng_channel_ok
$session_name $channel_name
611 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
612 start_lttng_tracing_ok
$session_name
613 $XML_VALIDATE $OUTPUT_DEST
614 ok $?
"Mi test: start xsd validation"
616 #Expect a true element
617 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
618 test "$result" = "true"
619 ok $?
"Mi test: mi report success on start command as expected"
621 #Extract session name from xml
622 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
623 test "$result" = "$session_name"
624 ok $?
"Mi test: started $session_name"
626 #Extract enabled expect true
627 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:enabled/text()" result
628 test "$result" = "true"
629 ok $?
"Mi test: enabled element : $result expected: true"
631 #Test metadata regenerate command
632 regenerate_metadata_ok
$session_name
633 $XML_VALIDATE $OUTPUT_DEST
634 ok $?
"Mi test: regenerate metadata"
637 stop_lttng_tracing_ok
$session_name
638 $XML_VALIDATE $OUTPUT_DEST
639 ok $?
"Mi test: stop xsd validation"
641 #Extract session name from xml
642 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
643 test "$result" = "$session_name"
644 ok $?
"Mi test: stopped $session_name"
646 #Extract enabled expect false
647 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:enabled/text()" result
648 test "$result" = "false"
649 ok $?
"Mi test: enabled element : $result expected: false"
651 #Test failing stop command
652 stop_lttng_tracing_fail
$session_name
653 $XML_VALIDATE $OUTPUT_DEST
654 ok $?
"Mi test: failed stop xsd validation"
656 #Expect a false element
657 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
658 test "$result" = "false"
659 ok $?
"Mi test: mi report failure on start command as expected"
663 destroy_lttng_sessions
666 function test_snapshot
() {
667 local session_name
="testSnapshotAdd"
668 local snapshot_path
="$OUTPUT_DIR/snapshotoutput"
669 OUTPUT_FILE
="snapshot.xml"
674 create_lttng_session_no_output
$session_name
677 #No channel enable start command should return element success false
678 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
679 lttng_snapshot_add_output_ok
$session_name $snapshot_path
680 $XML_VALIDATE $OUTPUT_DEST
681 ok $?
"Mi test: snapshot xsd validation"
683 #Expect a true element
684 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
685 test "$result" = "true"
686 ok $?
"Mi test: add snapshot is a success"
689 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:session_name/text()" result
690 test "$result" = "$session_name"
691 ok $?
"Mi test: added snapshot for: $result expected $session_name"
693 #Get name of generated output and id
694 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:name/text()" snapshot_name
695 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:id/text()" snapshot_id
698 lttng_snapshot_list
$session_name
699 $XML_VALIDATE $OUTPUT_DEST
700 ok $?
"Mi test: snapshot list xsd validation"
702 #Expect a true element
703 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
704 test "$result" = "true"
705 ok $?
"Mi test: add snapshot is a success"
707 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_LIST""/lttng:session[./lttng:name ='$session_name']/lttng:snapshots/lttng:snapshot/lttng:name/text()" result
708 test "$result" = "$snapshot_name"
709 ok $?
"Mi test: snapshot list extracted snapshot: $result expected: $snapshot_name"
712 lttng_snapshot_del_output_ok
$session_name $snapshot_id
713 $XML_VALIDATE $OUTPUT_DEST
714 ok $?
"Mi test: snapshot delete xsd validation"
717 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
718 test "$result" = "true"
719 ok $?
"Mi test: del snapshot is a success"
722 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/lttng:snapshot/lttng:id/text()" result
723 test "$result" = "$snapshot_id"
724 ok $?
"Mi test: snapshot del extracted snapshot id: $result expected: $snapshot_id"
726 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/lttng:snapshot/lttng:session_name/text()" result
727 test "$result" = "$session_name"
728 ok $?
"Mi test: snapshot del extracted snapshot id: $result expected: $session_name"
730 #Test fail on delete command
731 lttng_snapshot_del_output_fail
$session_name $snapshot_id
732 $XML_VALIDATE $OUTPUT_DEST
733 ok $?
"Mi test: snapshot delete xsd validation"
736 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
737 test "$result" = "false"
738 ok $?
"Mi test: del snapshot is a success"
741 destroy_lttng_sessions
744 function test_track_untrack
()
746 diag
"Test track/untrack pid"
748 local session_name
="testTrack"
750 OUTPUT_FILE
="track.xml"
754 create_lttng_session_no_output
$session_name
756 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
757 lttng_track_ok
"-p $pid -u"
758 $XML_VALIDATE $OUTPUT_DEST
759 ok $?
"Mi test: track pid xsd validation"
761 #Expect a true element
762 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
763 test "$result" = "true"
764 ok $?
"Mi test: track pid is a success"
766 #Verify that there is 3 process
767 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
768 num
=$
(echo "$result" |
wc -l)
770 ok $?
"Mi test: track pid expecting 3 processes got $num"
772 #Test the pid_tracker listing
773 list_lttng_with_opts
$session_name
774 $XML_VALIDATE $OUTPUT_DEST
775 ok $?
"Mi test: session list with pid_tracker validate"
777 #Check the good count
778 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
779 num
=$
(echo "$result" |
wc -l)
781 ok $?
"Mi test: tracker pid listing expecting 3 target got $num"
784 lttng_untrack_ok
"-p 2,3 -u"
785 $XML_VALIDATE $OUTPUT_DEST
786 ok $?
"Mi test: untrack pid xsd validation"
788 #Expect a true element
789 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
790 test "$result" = "true"
791 ok $?
"Mi test: untrack pid is a success"
793 #Verify that there is 2 untracked pids
794 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
795 num
=$
(echo "$result" |
wc -l)
797 ok $?
"Mi test: untrack pid expecting 2 process got $num"
799 #Check pid_tracker listing
800 list_lttng_with_opts
$session_name
801 $XML_VALIDATE $OUTPUT_DEST
802 ok $?
"Mi test: session list with pid_tracker validate"
804 #Check the good count
805 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
806 num
=$
(echo "$result" |
wc -l)
808 ok $?
"Mi test: tracker pid listing expecting 1 process got $num"
811 lttng_untrack_ok
"-p -u -a"
812 $XML_VALIDATE $OUTPUT_DEST
813 ok $?
"Mi test: untrack pid xsd validation"
815 #Expect a true element
816 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
817 test "$result" = "true"
818 ok $?
"Mi test: untrack all pid is a success"
820 #Verify that there is 1 untracked pid
821 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
822 num
=$
(echo "$result" |
wc -l)
824 ok $?
"Mi test: untrack pid expecting 1 process got $num"
826 #Test if the id is * which represent the all argument
828 ok $?
"Mi test: pid expected is * got $result"
830 #Test if pid_tracker is enabled as definied by pid_tracker
831 #behavior. If all pid are untrack than the pid_tracker is still
832 #enabled (pid_tracker node is present).
833 list_lttng_with_opts
$session_name
834 $XML_VALIDATE $OUTPUT_DEST
835 ok $?
"Mi test: session list with pid_tracker validate"
837 #Check the good count
838 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
839 num
=$
(echo -n "$result" |
wc -l)
841 ok $?
"Mi test: tracker pid listing expecting 0 process got $num"
844 lttng_track_ok
"-p -u -a"
845 $XML_VALIDATE $OUTPUT_DEST
846 ok $?
"Mi test: track pid xsd validation"
848 #Expect a true element
849 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
850 test "$result" = "true"
851 ok $?
"Mi test: track all pid is a success"
853 #Verify that there is 1 tracked process
854 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
855 num
=$
(echo "$result" |
wc -l)
857 ok $?
"Mi test: track pid expecting 1 process got $num"
859 #Test if the id is * wich represent the all argument
861 ok $?
"Mi test: pid expected is * got $result"
863 #Test if pid_tracker is enabled as definied by pid_tracker
864 #behavior. If all pid are untrack thant the pid_tracker is
865 #disabled (node pid_tracker do not exist)
866 list_lttng_with_opts
$session_name
867 $XML_VALIDATE $OUTPUT_DEST
868 ok $?
"Mi test: session list with pid_tracker validate"
870 node_check_xml
$OUTPUT_DEST $XPATH_PID_TRACKER result
872 ok $?
"Mi test: Pid_tracker node is absent as defined"
875 destroy_lttng_sessions
878 function test_add_context_list
()
880 diag
"Test context listing"
882 OUTPUT_FILE
="list-context.xml"
883 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
884 lttng_add_context_list
886 $XML_VALIDATE $OUTPUT_DEST
887 ok $?
"Mi test: context listing validation"
890 start_lttng_sessiond
$SESSIOND_LOAD_DIR
905 test_list_session_long_path
906 test_add_context_list
911 for fct_test
in ${TESTS[@]};
914 if [ $?
-ne 0 ]; then
921 OUTPUT_DEST
=/dev
/null
2>&1