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
23 SESSIOND_BIN
="lttng-sessiond"
24 RELAYD_BIN
="lttng-relayd"
26 #Test app for ust event
27 TESTAPP_PATH
="$TESTDIR/utils/testapp"
28 TESTAPP_NAME
="gen-ust-events"
29 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
34 OUTPUT_DIR
=$
(mktemp
-d)
35 FOO_LOAD_DIR
=$
(mktemp
-d)
36 OUTPUT_FILE
="default.xml"
38 #Path to custom xml utilities
39 XML_VALIDATE
="$CURDIR/validate_xml $XSD_PATH"
40 XML_EXTRACT
="$CURDIR/extract_xml"
41 XML_NODE_CHECK
="$CURDIR/extract_xml -e"
43 XPATH_CMD_OUTPUT
="//lttng:command/lttng:output"
44 XPATH_COMMAND_SUCCESS
="/lttng:command/lttng:success/text()"
45 XPATH_SESSION
="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session"
46 XPATH_ENABLE_CHANNEL_NAME
="$XPATH_CMD_OUTPUT/lttng:channels/lttng:channel/lttng:name/text()"
47 XPATH_ENABLE_EVENT_SUCCESS
="$XPATH_CMD_OUTPUT/lttng:events/lttng:event/lttng:success/text()"
48 XPATH_DISABLE_EVENT_SUCCESS
="$XPATH_CMD_OUTPUT/lttng:channel/lttng:events/lttng:event/lttng:success/text()"
49 XPATH_LIST_DOMAIN
="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain"
50 XPATH_LIST_CHANNEL
="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel"
51 XPATH_LIST_UST_EVENT
="$XPATH_CMD_OUTPUT/lttng:domains/lttng:domain[./lttng:type ='UST']/lttng:pids/lttng:pid/lttng:events/lttng:event"
52 XPATH_SNAPSHOT_ADD_SNAPSHOT
="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'add-output']/lttng:output"
53 XPATH_SNAPSHOT_LIST
="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'list-output']/lttng:output"
54 XPATH_SNAPSHOT_DEL
="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'del-output']/lttng:output"
55 XPATH_TRACK_UNTRACK_PID
="$XPATH_CMD_OUTPUT/lttng:targets/lttng:pid_target"
56 XPATH_PID_TRACKER
="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:trackers/lttng:pid_tracker"
58 DEVNULL
=/dev
/null
2>&1
60 DIR
=$
(readlink
-f $TESTDIR)
64 source $TESTDIR/utils
/utils.sh
66 #Overwrite the lttng_bin to get mi output
67 LTTNG_BIN
="lttng --mi xml"
69 #Global declaration for simplification
70 LTTNG
=$TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN
72 #Overwrite the default output for utils.sh command
74 #MUST set TESTDIR before calling those functions
77 print_test_banner
"$TEST_DESC"
79 function extract_xml
()
85 output
=$
($XML_EXTRACT $xml "$xpath")
86 ok $?
"Extraction of xpath $xpath"
87 eval $__result="'$output'"
90 function node_check_xml
()
96 output
=$
($XML_NODE_CHECK $xml "$xpath")
97 ok $?
"Check of node existence with xpath $xpath"
98 eval $__result="'$output'"
101 # Arg1 is path to xml file
103 # is true if we expected the success element to be false
107 function is_command_success
()
110 local expect_false
=$2
112 local xpath
=$XPATH_COMMAND_SUCCESS
115 #Extract the success element
117 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
118 if [[ $expect_false = "true" ]]; then
119 if [[ $result ]]; then
120 pass
"Mi test: $xml command failed as expected"
122 fail
"Mi test: $xml command did not fail as expected"
125 if [[ $result ]]; then
126 pass
"Mi test: $xml command success"
128 fail
"Mi test: $xml command failed"
133 function mi_print_version
()
138 $LTTNG version
$opt > $output_path
139 ok $?
"MI test: Lttng version"
143 function test_version
()
145 OUTPUT_FILE
="version.xml"
146 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
147 mi_print_version
$OUTPUT_DEST
148 $XML_VALIDATE $OUTPUT_DEST
149 ok $?
"MI test: Version xsd validation"
152 function test_create_session
()
154 local session_name
="testSession"
156 OUTPUT_FILE
="create_session.xml"
157 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
158 create_lttng_session_ok
$session_name $OUTPUT_DIR
159 $XML_VALIDATE $OUTPUT_DEST
160 ok $?
"MI test: create session xsd validation"
162 #try to recreate a session. Expecting it to fail
163 create_lttng_session_fail
$session_name $OUTPUT_DIR
164 $XML_VALIDATE $OUTPUT_DEST
165 ok $?
"MI test: expecting fail create session xsd validation"
166 is_command_success
$OUTPUT_DEST true
169 destroy_lttng_session_ok
$session_name
172 function test_destroy_session
()
179 OUTPUT_FILE
="destroy_session.xml"
183 for (( i
= 0; i
< 3; i
++ )); do
184 create_lttng_session_ok
${session_name[$i]} $OUTPUT_DIR
187 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
188 destroy_lttng_session_ok
${session_name[0]}
189 $XML_VALIDATE $OUTPUT_DEST
190 ok $?
"MI test: destroy session ${session_name[0]} xsd validation"
192 #Verify that we destroyed the good session
193 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
194 test "$result" = "${session_name[0]}"
195 ok $?
"Mi test: deleted session: $result expected: ${session_name[0]}"
197 #Destroy all and count:should be 2
198 destroy_lttng_sessions
199 $XML_VALIDATE $OUTPUT_DEST
200 ok $?
"MI test: destroy all session xsd validation"
202 #Verify that we destroyed 2 sessions
203 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
204 num
=$
(echo "$result" |
wc -l)
206 ok $?
"Mi test: $num / 2 sessions discovered"
208 #Verify that if no session is present command fail and mi report it.
209 destroy_lttng_session_fail
${session_name[0]}
210 $XML_VALIDATE $OUTPUT_DEST
211 ok $?
"MI test: failing destroy session ${session_name[0]} xsd validation"
212 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
213 test "$result" = "false"
214 ok $?
"Mi test: destroy command on ${session_name[0]} failed as expected"
218 function test_list_sessions
()
225 OUTPUT_FILE
="list_sessions.xml"
229 for (( i
= 0; i
< 3; i
++ )); do
230 create_lttng_session_ok
${session_name[$i]} $OUTPUT_DIR
233 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
235 $XML_VALIDATE $OUTPUT_DEST
236 ok $?
"Mi test: list sessions xsd validation"
238 #We should have 3 session
239 extract_xml
$OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result
240 num
=$
(echo "$result" |
wc -l)
242 ok $?
"Mi test: $num / 3 sessions discovered"
246 destroy_lttng_sessions
249 function test_list_session_long_path
()
251 local session_name
="session_long_path"
253 output_basedir
=$OUTPUT_DIR/$
(randstring
254 0)
254 mkdir
-p ${output_basedir}
256 OUTPUT_FILE
="list_sessions.xml"
260 create_lttng_session_ok
$session_name ${output_basedir}
262 OUTPUT_DEST
=${output_basedir}/$OUTPUT_FILE
264 $XML_VALIDATE $OUTPUT_DEST
265 ok $?
"Mi test: list session with long path xsd validation"
269 destroy_lttng_sessions
271 function test_ust_channel
()
273 local session_name
="testsession"
274 local channel_name
=("channelUst0"
278 OUTPUT_FILE
="ust_channel.xml"
282 create_lttng_session_ok
$session_name $OUTPUT_DIR
284 #Test the enable_channel command
285 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
286 enable_ust_lttng_channel_ok
$session_name ${channel_name[0]}
287 $XML_VALIDATE $OUTPUT_DEST
288 ok $?
"Mi test: enable ust channel xsd validation"
289 is_command_success
$OUTPUT_DEST false
291 #Expect the command to fail
292 enable_ust_lttng_channel_fail
$session_name ${channel_name[0]}
293 $XML_VALIDATE $OUTPUT_DEST
294 ok $?
"Mi test: fail enable ust channel xsd validation"
295 is_command_success
$OUTPUT_DEST true
297 #Create two ust channel to test multiple disable
298 for (( i
= 1; i
< 3; i
++ )); do
299 enable_ust_lttng_channel_ok
$session_name ${channel_name[$i]}
302 #Test the disable_channel command
303 disable_ust_lttng_channel
$session_name ${channel_name[0]}
304 $XML_VALIDATE $OUTPUT_DEST
305 ok $?
"Mi test: disable ust channel xsd validation"
306 is_command_success
$OUTPUT_DEST false
307 #Check that we delete the good channel
308 extract_xml
$OUTPUT_DEST $XPATH_ENABLE_CHANNEL_NAME result
309 test "$result" = "${channel_name[0]}"
310 ok $?
"MI test: ${channel_name[0]} disabled"
312 #Test multiple disable_channel;
313 disable_ust_lttng_channel
$session_name ${channel_name[1]},${channel_name[2]}
314 $XML_VALIDATE $OUTPUT_DEST
315 ok $?
"Mi test: multiple disable ust channel xsd validation"
316 is_command_success
$OUTPUT_DEST false
318 #Make sure we have two disabled channel
319 extract_xml
$OUTPUT_DEST $XPATH_ENABLE_CHANNEL_NAME result
320 local num
=$
(echo "$result" |
wc -l)
322 ok $?
"Mi test: disabled ust channel $num/2"
326 destroy_lttng_sessions
330 function test_ust_lttng_event
()
332 local session_name
="testSession"
333 local channel_name
="testChannel"
334 local event
=("ev1" "ev2" "ev3")
336 OUTPUT_FILE
="ust_event.xml"
340 create_lttng_session_ok
$session_name $OUTPUT_DIR
341 enable_ust_lttng_channel_ok
$session_name $channel_name
343 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
344 #Test the enable event for ust domain
345 enable_ust_lttng_event_ok
$session_name ${event[0]} $channel_name
346 $XML_VALIDATE $OUTPUT_DEST
347 ok $?
"Mi test: Enable_event for ust domain xsd validation"
348 is_command_success
$OUTPUT_DEST false
350 #Try to reenable an enabled event. Should fail
351 enable_ust_lttng_event_fail
$session_name ${event[0]} $channel_name
352 $XML_VALIDATE $OUTPUT_DEST
353 ok $?
"Mi test: Fail enable_event for ust domain xsd validation"
354 is_command_success
$OUTPUT_DEST true
356 #Enable multiple event including the last one command will fail
357 #But 2 events should success
359 #Nice little hack, create a string ev,ev,ev
360 #IFS stand for Internal field separator
361 #Event[*] print all the element inside the array with the IFS in between
362 concat_event
=$
( IFS
=$
','; echo "${event[*]}" )
364 enable_ust_lttng_event_fail
$session_name $concat_event $channel_name
365 $XML_VALIDATE $OUTPUT_DEST
366 ok $?
"Mi test: Multiple enable ust event with inside fail xsd validation"
368 #Check for 2 success = true and 1 success = false
369 extract_xml
$OUTPUT_DEST $XPATH_ENABLE_EVENT_SUCCESS result
370 num_ocur
=$
(grep -o "true" <<< "$result" |
wc -l)
371 test "$num_ocur" -eq "2"
372 ok $?
"Mi test: Enabled event on failing enable command $num_ocur_true/2"
374 extract_xml
$OUTPUT_DEST $XPATH_ENABLE_EVENT_SUCCESS result
375 num_ocur
=$
(grep -o "false" <<< "$result" |
wc -l)
376 test "$num_ocur" -eq "1"
377 ok $?
"Mi test: Enabled event on failing enable command $num_ocur_true/2"
380 disable_ust_lttng_event
$session_name ${event[0]} $channel_name
381 $XML_VALIDATE $OUTPUT_DEST
382 ok $?
"Mi test: Disable ust event xsd validation"
383 is_command_success
$OUTPUT_DEST false
385 #Disable the 3 event combined. Should pass
386 disable_ust_lttng_event
$session_name $concat_event $channel_name
387 $XML_VALIDATE $OUTPUT_DEST
388 ok $?
"Mi test: Disable multiple ust event xsd validation"
389 is_command_success
$OUTPUT_DEST false
391 #Make sure we have 3 inner success
392 extract_xml
$OUTPUT_DEST $XPATH_DISABLE_EVENT_SUCCESS result
393 num_ocur
=$
(grep -o "true" <<< "$result" |
wc -l)
394 test "$num_ocur" -eq "3"
395 ok $?
"Mi test: Disable multiple ust event success $num_ocur/3"
399 destroy_lttng_sessions
402 function test_list_channel
()
404 local session_name
="testSession"
405 local channel_name
="testChannel"
406 local event
=("ev1" "ev2" "ev3")
408 OUTPUT_FILE
="list_channel.xml"
412 create_lttng_session_ok
$session_name $OUTPUT_DIR
413 enable_ust_lttng_channel_ok
$session_name $channel_name
415 #Enable ust and jul events
416 concat_event
=$
( IFS
=$
','; echo "${event[*]}" )
417 enable_ust_lttng_event_ok
$session_name $concat_event $channel_name
420 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
421 list_lttng_with_opts
"$session_name -c $channel_name"
422 $XML_VALIDATE $OUTPUT_DEST
423 ok $?
"Mi test: list channel xsd validation"
425 #Expect 1 domain: UST
426 extract_xml
$OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result
427 num
=$
(echo "$result" |
wc -l)
429 ok $?
"Mi test: $num / 1 domains discovered"
431 #Expect 1 channel: test
432 extract_xml
$OUTPUT_DEST $XPATH_LIST_CHANNEL"/lttng:name/text()" result
433 num
=$
(echo "$result" |
wc -l)
435 ok $?
"Mi test: $num / 1 channel discovered"
437 test "$result" = "$channel_name"
438 ok $?
"Mi test: expected channel: $channel_name found: $result"
440 #Add a channel and make sure we have 2 channel now
442 enable_ust_lttng_channel_ok
$session_name $channel_name"a"
446 destroy_lttng_sessions
449 function test_list_domain
()
451 local session_name
="testSession"
452 local channel_name
="testChannel"
453 local event
=("ev1" "ev2" "ev3")
455 OUTPUT_FILE
="list_domain.xml"
459 create_lttng_session_ok
$session_name $OUTPUT_DIR
460 enable_ust_lttng_channel_ok
$session_name $channel_name
462 #Enable ust and jul events
463 concat_event
=$
( IFS
=$
','; echo "${event[*]}" )
464 enable_ust_lttng_event_ok
$session_name $concat_event $channel_name
465 enable_jul_lttng_event
$session_name $concat_event $channel_name
468 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
469 list_lttng_with_opts
"$session_name -d"
470 $XML_VALIDATE $OUTPUT_DEST
471 ok $?
"Mi test: list domain xsd validation"
473 #Expect 2 domain: Jul and UST
474 extract_xml
$OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result
475 num
=$
(echo "$result" |
wc -l)
477 ok $?
"Mi test: $num / 2 domains discovered"
479 #Test for valid value
480 if [[ "$result" = *"JUL"* ]]; then
481 pass
"Mi test: domains Jul is present"
483 fail
"Mi test: domains Jul is absent"
486 if [[ "$result" = *"UST"* ]]; then
487 pass
"Mi test: domains UST is present"
489 fail
"Mi test: domains UST is absent"
494 destroy_lttng_sessions
497 function test_list_session
()
499 local session_name
="testSession"
500 local channel_name
="testChannel"
501 local event
=("ev1" "ev2" "ev3")
503 OUTPUT_FILE
="list_session.xml"
507 create_lttng_session_ok
$session_name $OUTPUT_DIR
508 enable_ust_lttng_channel_ok
$session_name $channel_name
510 #Enable ust and jul events
511 concat_event
=$
( IFS
=$
','; echo "${event[*]}" )
512 enable_ust_lttng_event_ok
$session_name $concat_event $channel_name
513 enable_jul_lttng_event
$session_name $concat_event $channel_name
516 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
517 list_lttng_with_opts
$session_name
518 $XML_VALIDATE $OUTPUT_DEST
519 ok $?
"Mi test: list session xsd validation"
521 #Expect 2 domain: Jul and UST
522 extract_xml
$OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result
523 num
=$
(echo "$result" |
wc -l)
525 ok $?
"Mi test: $num / 2 domains discovered"
527 #Expect 2 channel: test and lttng_jul_event
528 extract_xml
$OUTPUT_DEST $XPATH_LIST_CHANNEL"/lttng:name/text()" result
529 num
=$
(echo "$result" |
wc -l)
531 ok $?
"Mi test: $num / 2 channel discovered"
535 destroy_lttng_sessions
538 function test_list_ust_event
()
540 local file_sync_after_first
=$
(mktemp
-u)
541 local file_sync_before_last
=$
(mktemp
-u)
543 OUTPUT_FILE
="list_ust_event.xml"
546 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
549 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${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 $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"
751 local snapshot_path
="$OUTPUT_DIR/trackoutput"
753 OUTPUT_FILE
="track.xml"
757 create_lttng_session_no_output
$session_name
759 OUTPUT_DEST
=$OUTPUT_DIR/$OUTPUT_FILE
760 lttng_track_ok
"-p $pid -u"
761 $XML_VALIDATE $OUTPUT_DEST
762 ok $?
"Mi test: track pid xsd validation"
764 #Expect a true element
765 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
766 test "$result" = "true"
767 ok $?
"Mi test: track pid is a success"
769 #Verify that there is 3 process
770 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
771 num
=$
(echo "$result" |
wc -l)
773 ok $?
"Mi test: track pid expecting 3 processes got $num"
775 #Test the pid_tracker listing
776 list_lttng_with_opts
$session_name
777 $XML_VALIDATE $OUTPUT_DEST
778 ok $?
"Mi test: session list with pid_tracker validate"
780 #Check the good count
781 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
782 num
=$
(echo "$result" |
wc -l)
784 ok $?
"Mi test: tracker pid listing expecting 3 target got $num"
787 lttng_untrack_ok
"-p 2,3 -u"
788 $XML_VALIDATE $OUTPUT_DEST
789 ok $?
"Mi test: untrack pid xsd validation"
791 #Expect a true element
792 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
793 test "$result" = "true"
794 ok $?
"Mi test: untrack pid is a success"
796 #Verify that there is 2 untracked pids
797 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
798 num
=$
(echo "$result" |
wc -l)
800 ok $?
"Mi test: untrack pid expecting 2 process got $num"
802 #Check pid_tracker listing
803 list_lttng_with_opts
$session_name
804 $XML_VALIDATE $OUTPUT_DEST
805 ok $?
"Mi test: session list with pid_tracker validate"
807 #Check the good count
808 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
809 num
=$
(echo "$result" |
wc -l)
811 ok $?
"Mi test: tracker pid listing expecting 1 process got $num"
814 lttng_untrack_ok
"-p -u -a"
815 $XML_VALIDATE $OUTPUT_DEST
816 ok $?
"Mi test: untrack pid xsd validation"
818 #Expect a true element
819 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
820 test "$result" = "true"
821 ok $?
"Mi test: untrack all pid is a success"
823 #Verify that there is 1 untracked pid
824 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
825 num
=$
(echo "$result" |
wc -l)
827 ok $?
"Mi test: untrack pid expecting 1 process got $num"
829 #Test if the id is * which represent the all argument
831 ok $?
"Mi test: pid expected is * got $result"
833 #Test if pid_tracker is enabled as definied by pid_tracker
834 #behavior. If all pid are untrack than the pid_tracker is still
835 #enabled (pid_tracker node is present).
836 list_lttng_with_opts
$session_name
837 $XML_VALIDATE $OUTPUT_DEST
838 ok $?
"Mi test: session list with pid_tracker validate"
840 #Check the good count
841 extract_xml
$OUTPUT_DEST $XPATH_PID_TRACKER"/lttng:targets/lttng:pid_target/lttng:pid" result
842 num
=$
(echo -n "$result" |
wc -l)
844 ok $?
"Mi test: tracker pid listing expecting 0 process got $num"
847 lttng_track_ok
"-p -u -a"
848 $XML_VALIDATE $OUTPUT_DEST
849 ok $?
"Mi test: track pid xsd validation"
851 #Expect a true element
852 extract_xml
$OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
853 test "$result" = "true"
854 ok $?
"Mi test: track all pid is a success"
856 #Verify that there is 1 tracked process
857 extract_xml
$OUTPUT_DEST $XPATH_TRACK_UNTRACK_PID"/lttng:pid" result
858 num
=$
(echo "$result" |
wc -l)
860 ok $?
"Mi test: track pid expecting 1 process got $num"
862 #Test if the id is * wich represent the all argument
864 ok $?
"Mi test: pid expected is * got $result"
866 #Test if pid_tracker is enabled as definied by pid_tracker
867 #behavior. If all pid are untrack thant the pid_tracker is
868 #disabled (node pid_tracker do not exist)
869 list_lttng_with_opts
$session_name
870 $XML_VALIDATE $OUTPUT_DEST
871 ok $?
"Mi test: session list with pid_tracker validate"
873 node_check_xml
$OUTPUT_DEST $XPATH_PID_TRACKER result
875 ok $?
"Mi test: Pid_tracker node is absent as defined"
878 destroy_lttng_sessions
881 start_lttng_sessiond
$FOO_LOAD_DIR
896 test_list_session_long_path
901 for fct_test
in ${TESTS[@]};
904 if [ $?
-ne 0 ]; then
910 OUTPUT_DEST
=/dev
/null
2>&1