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 -i $NR_ITER -w $NR_USEC_WAIT \
548 --sync-after-first-event ${file_sync_after_first} \
549 --sync-before-last-event ${file_sync_before_last} & 2>/dev
/null
551 while [ ! -f "${file_sync_after_first}" ]; do
555 list_lttng_with_opts
"-u -f"
557 touch ${file_sync_before_last}
559 $XML_VALIDATE $OUTPUT_DEST
560 ok $?
"Mi test: list ust event xsd validation"
563 extract_xml
$OUTPUT_DEST "$XPATH_LIST_UST_EVENT""/lttng:name/text()" result
564 num
=$
(echo "$result" |
wc -l)
566 #Since the number of events is prone to change we only look for >= from a
567 #base number. An alternative would be to look for each events but this
568 #is complicated for nothing.
570 ok $?
"Mi test: $num / 5 ust events discovered"
572 #Extract field from tp:tptest event. Expect >= to 12 because number of
573 #field is prone to change.
574 extract_xml
$OUTPUT_DEST "$XPATH_LIST_UST_EVENT""[./lttng:name = 'tp:tptest']/lttng:event_fields/lttng:event_field/lttng:name/text()" result
575 num
=$
(echo "$result" |
wc -l)
577 ok $?
"Mi test: $num / 12 ust event fields discovered"
579 #Wait for all background processes
582 rm -f ${file_sync_after_first}
583 rm -f ${file_sync_before_last}
586 function test_start_stop
() {
587 local session_name
="testStartStopSession"
588 local channel_name
="startStopChannel"
590 OUTPUT_FILE
="list_start_stop.xml"
594 create_lttng_session_ok
$session_name $OUTPUT_DIR
597 #No channel enable start command should return element success false
598 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
599 start_lttng_tracing_fail
$session_name
600 $XML_VALIDATE $OUTPUT_DEST
601 ok $?
"Mi test: failed start xsd validation"
603 #Expect a false element
604 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
605 test "$result" = "false"
606 ok $?
"Mi test: mi report failure on start command as expected"
608 #Enable a channel to test success
610 enable_ust_lttng_channel_ok
$session_name $channel_name
613 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
614 start_lttng_tracing_ok
$session_name
615 $XML_VALIDATE $OUTPUT_DEST
616 ok $?
"Mi test: start xsd validation"
618 #Expect a true element
619 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
620 test "$result" = "true"
621 ok $?
"Mi test: mi report success on start command as expected"
623 #Extract session name from xml
624 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
625 test "$result" = "$session_name"
626 ok $?
"Mi test: started $session_name"
628 #Extract enabled expect true
629 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:enabled/text()" result
630 test "$result" = "true"
631 ok $?
"Mi test: enabled element : $result expected: true"
633 #Test metadata regenerate command
634 regenerate_metadata_ok
$session_name
635 $XML_VALIDATE $OUTPUT_DEST
636 ok $?
"Mi test: regenerate metadata"
639 stop_lttng_tracing_ok
$session_name
640 $XML_VALIDATE $OUTPUT_DEST
641 ok $?
"Mi test: stop xsd validation"
643 #Extract session name from xml
644 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
645 test "$result" = "$session_name"
646 ok $?
"Mi test: stopped $session_name"
648 #Extract enabled expect false
649 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:enabled/text()" result
650 test "$result" = "false"
651 ok $?
"Mi test: enabled element : $result expected: false"
653 #Test failing stop command
654 stop_lttng_tracing_fail
$session_name
655 $XML_VALIDATE $OUTPUT_DEST
656 ok $?
"Mi test: failed stop xsd validation"
658 #Expect a false element
659 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
660 test "$result" = "false"
661 ok $?
"Mi test: mi report failure on start command as expected"
665 destroy_lttng_sessions
668 function test_snapshot
() {
669 local session_name
="testSnapshotAdd"
670 local snapshot_path
="$OUTPUT_DIR/snapshotoutput"
671 OUTPUT_FILE
="snapshot.xml"
676 create_lttng_session_no_output
$session_name
679 #No channel enable start command should return element success false
680 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
681 lttng_snapshot_add_output_ok
$session_name file://$snapshot_path
682 $XML_VALIDATE $OUTPUT_DEST
683 ok $?
"Mi test: snapshot xsd validation"
685 #Expect a true element
686 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
687 test "$result" = "true"
688 ok $?
"Mi test: add snapshot is a success"
691 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:session_name/text()" result
692 test "$result" = "$session_name"
693 ok $?
"Mi test: added snapshot for: $result expected $session_name"
695 #Get name of generated output and id
696 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:name/text()" snapshot_name
697 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:id/text()" snapshot_id
700 lttng_snapshot_list
$session_name
701 $XML_VALIDATE $OUTPUT_DEST
702 ok $?
"Mi test: snapshot list xsd validation"
704 #Expect a true element
705 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
706 test "$result" = "true"
707 ok $?
"Mi test: add snapshot is a success"
709 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_LIST""/lttng:session[./lttng:name ='$session_name']/lttng:snapshots/lttng:snapshot/lttng:name/text()" result
710 test "$result" = "$snapshot_name"
711 ok $?
"Mi test: snapshot list extracted snapshot: $result expected: $snapshot_name"
714 lttng_snapshot_del_output_ok
$session_name $snapshot_id
715 $XML_VALIDATE $OUTPUT_DEST
716 ok $?
"Mi test: snapshot delete xsd validation"
719 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
720 test "$result" = "true"
721 ok $?
"Mi test: del snapshot is a success"
724 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/lttng:snapshot/lttng:id/text()" result
725 test "$result" = "$snapshot_id"
726 ok $?
"Mi test: snapshot del extracted snapshot id: $result expected: $snapshot_id"
728 extract_xml
$OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/lttng:snapshot/lttng:session_name/text()" result
729 test "$result" = "$session_name"
730 ok $?
"Mi test: snapshot del extracted snapshot id: $result expected: $session_name"
732 #Test fail on delete command
733 lttng_snapshot_del_output_fail
$session_name $snapshot_id
734 $XML_VALIDATE $OUTPUT_DEST
735 ok $?
"Mi test: snapshot delete xsd validation"
738 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
739 test "$result" = "false"
740 ok $?
"Mi test: del snapshot is a success"
743 destroy_lttng_sessions
746 function test_track_untrack
()
748 diag
"Test track/untrack pid"
750 local session_name
="testTrack"
752 OUTPUT_FILE
="track.xml"
756 create_lttng_session_no_output
$session_name
758 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
759 lttng_track_ok
"-p $pid -u"
760 $XML_VALIDATE $OUTPUT_DEST
761 ok $?
"Mi test: track pid xsd validation"
763 #Expect a true element
764 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
765 test "$result" = "true"
766 ok $?
"Mi test: track pid is a success"
768 #Verify that there is 3 process
769 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
770 num
=$
(echo "$result" |
wc -l)
772 ok $?
"Mi test: track pid expecting 3 processes got $num"
774 #Test the pid_tracker listing
775 list_lttng_with_opts
$session_name
776 $XML_VALIDATE $OUTPUT_DEST
777 ok $?
"Mi test: session list with pid_tracker validate"
779 #Check the good count
780 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
781 num
=$
(echo "$result" |
wc -l)
783 ok $?
"Mi test: tracker pid listing expecting 3 target got $num"
786 lttng_untrack_ok
"-p 2,3 -u"
787 $XML_VALIDATE $OUTPUT_DEST
788 ok $?
"Mi test: untrack pid xsd validation"
790 #Expect a true element
791 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
792 test "$result" = "true"
793 ok $?
"Mi test: untrack pid is a success"
795 #Verify that there is 2 untracked pids
796 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
797 num
=$
(echo "$result" |
wc -l)
799 ok $?
"Mi test: untrack pid expecting 2 process got $num"
801 #Check pid_tracker listing
802 list_lttng_with_opts
$session_name
803 $XML_VALIDATE $OUTPUT_DEST
804 ok $?
"Mi test: session list with pid_tracker validate"
806 #Check the good count
807 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
808 num
=$
(echo "$result" |
wc -l)
810 ok $?
"Mi test: tracker pid listing expecting 1 process got $num"
813 lttng_untrack_ok
"-p -u -a"
814 $XML_VALIDATE $OUTPUT_DEST
815 ok $?
"Mi test: untrack pid xsd validation"
817 #Expect a true element
818 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
819 test "$result" = "true"
820 ok $?
"Mi test: untrack all pid is a success"
822 #Verify that there is 1 untracked pid
823 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
824 num
=$
(echo "$result" |
wc -l)
826 ok $?
"Mi test: untrack pid expecting 1 process got $num"
828 #Test if the id is * which represent the all argument
830 ok $?
"Mi test: pid expected is * got $result"
832 #Test if pid_tracker is enabled as definied by pid_tracker
833 #behavior. If all pid are untrack than the pid_tracker is still
834 #enabled (pid_tracker node is present).
835 list_lttng_with_opts
$session_name
836 $XML_VALIDATE $OUTPUT_DEST
837 ok $?
"Mi test: session list with pid_tracker validate"
839 #Check the good count
840 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
841 num
=$
(echo -n "$result" |
wc -l)
843 ok $?
"Mi test: tracker pid listing expecting 0 process got $num"
846 lttng_track_ok
"-p -u -a"
847 $XML_VALIDATE $OUTPUT_DEST
848 ok $?
"Mi test: track pid xsd validation"
850 #Expect a true element
851 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
852 test "$result" = "true"
853 ok $?
"Mi test: track all pid is a success"
855 #Verify that there is 1 tracked process
856 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
857 num
=$
(echo "$result" |
wc -l)
859 ok $?
"Mi test: track pid expecting 1 process got $num"
861 #Test if the id is * wich represent the all argument
863 ok $?
"Mi test: pid expected is * got $result"
865 #Test if pid_tracker is enabled as definied by pid_tracker
866 #behavior. If all pid are untrack thant the pid_tracker is
867 #disabled (node pid_tracker do not exist)
868 list_lttng_with_opts
$session_name
869 $XML_VALIDATE $OUTPUT_DEST
870 ok $?
"Mi test: session list with pid_tracker validate"
872 node_check_xml
$OUTPUT_DEST $XPATH_PID_TRACKER result
874 ok $?
"Mi test: Pid_tracker node is absent as defined"
877 destroy_lttng_sessions
880 function test_add_context_list
()
882 diag
"Test context listing"
884 OUTPUT_FILE
="list-context.xml"
885 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
886 lttng_add_context_list
888 $XML_VALIDATE $OUTPUT_DEST
889 ok $?
"Mi test: context listing validation"
892 start_lttng_sessiond
$SESSIOND_LOAD_DIR
907 test_list_session_long_path
908 test_add_context_list
913 for fct_test
in ${TESTS[@]};
916 if [ $?
-ne 0 ]; then
923 OUTPUT_DEST
=/dev
/null
2>&1