Mi test: make sure to not auto load session when using lttng-sessiond
[lttng-tools.git] / tests / regression / tools / mi / test_mi
1 #!/bin/bash
2 #
3 # Copyright (C) - 2014 Jonathan Rajotte <jonathan.r.julien@gmail.com>
4 #
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.
8 #
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
12 # details.
13 #
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
17
18 TEST_DESC="Machine interface testing"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../../
22 XSD_PATH=$TESTDIR/../src/common/mi_lttng.xsd
23 SESSIOND_BIN="lttng-sessiond"
24 RELAYD_BIN="lttng-relayd"
25
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"
30 NR_USEC_WAIT=10000
31
32
33 #Temp file output
34 OUTPUT_DIR=$(mktemp -d)
35 FOO_LOAD_DIR=$(mktemp -d)
36 OUTPUT_FILE="default.xml"
37
38 #Path to custom xml utilities
39 XML_VALIDATE="$CURDIR/validate_xml $XSD_PATH"
40 XML_EXTRACT="$CURDIR/extract_xml"
41
42 XPATH_CMD_OUTPUT="//command/output"
43 XPATH_COMMAND_SUCCESS="/command/success/text()"
44 XPATH_SESSION="$XPATH_CMD_OUTPUT/sessions/session"
45 XPATH_ENABLE_CHANNEL_NAME="$XPATH_CMD_OUTPUT/channels/channel/name/text()"
46 XPATH_ENABLE_EVENT_SUCCESS="$XPATH_CMD_OUTPUT/events/event/success/text()"
47 XPATH_DISABLE_EVENT_SUCCESS="$XPATH_CMD_OUTPUT/channel/events/event/success/text()"
48 XPATH_LIST_DOMAIN="$XPATH_CMD_OUTPUT/sessions/session/domains/domain"
49 XPATH_LIST_CHANNEL="$XPATH_CMD_OUTPUT/sessions/session/domains/domain/channels/channel"
50 XPATH_LIST_UST_EVENT="$XPATH_CMD_OUTPUT/domains/domain[./type = 'UST']/pids/pid/events/event"
51 XPATH_SNAPSHOT_ADD_SNAPSHOT="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'add-output']/output"
52 XPATH_SNAPSHOT_LIST="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'list-output']/output"
53 XPATH_SNAPSHOT_DEL="$XPATH_CMD_OUTPUT/snapshot_action[./name = 'del-output']/output"
54
55 DEVNULL=/dev/null 2>&1
56
57 DIR=$(readlink -f $TESTDIR)
58
59 NUM_TESTS=178
60
61 source $TESTDIR/utils/utils.sh
62
63 #Overwrite the lttng_bin to get mi output
64 LTTNG_BIN="lttng --mi xml"
65
66 #Global devlaration for simplification
67 LTTNG=$TESTDIR/../src/bin/lttng/$LTTNG_BIN
68
69 #Overwrite the default output for utils.sh command
70
71 #MUST set TESTDIR before calling those functions
72 plan_tests $NUM_TESTS
73
74 print_test_banner "$TEST_DESC"
75
76 function extract_xml ()
77 {
78 local xml=$1
79 local xpath=$2
80 local __result=$3
81 local output
82 output=$($XML_EXTRACT $xml "$xpath")
83 ok $? "Extraction of xpath $xpath"
84 eval $__result="'$output'"
85 }
86
87 # Arg1 is path to xml file
88 # Arg2:
89 # is true if we expected the success element to be false
90 # else
91 # passe false
92
93 function is_command_success ()
94 {
95 local xml=$1
96 local expect_false=$2
97
98 local xpath=$XPATH_COMMAND_SUCCESS
99
100 #Extract the success element
101 #expect false
102 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
103 if [[ $expect_false = "true" ]]; then
104 if [[ $result ]]; then
105 pass "Mi test: $xml command failed as expected"
106 else
107 fail "Mi test: $xml command did not fail as expected"
108 fi
109 else
110 if [[ $result ]]; then
111 pass "Mi test: $xml command success"
112 else
113 fail "Mi test: $xml command failed"
114 fi
115 fi
116 }
117
118 function mi_print_version ()
119 {
120 local opt=$2
121 local output_path=$1
122
123 $LTTNG version $opt > $1
124 ok $? "MI test: Lttng version"
125
126 }
127
128 function test_version ()
129 {
130 OUTPUT_FILE="version.xml"
131 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
132 mi_print_version $OUTPUT_DEST
133 $XML_VALIDATE $OUTPUT_DEST
134 ok $? "MI test: Version xsd validation"
135 }
136
137 function test_create_session ()
138 {
139 local session_name="testSession"
140
141 OUTPUT_FILE="create_session.xml"
142 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
143 create_lttng_session $session_name $OUTPUT_DIR
144 $XML_VALIDATE $OUTPUT_DEST
145 ok $? "MI test: create session xsd validation"
146
147 #try to recreate a session. Expecting it to fail
148 create_lttng_session $session_name $OUTPUT_DIR true
149 $XML_VALIDATE $OUTPUT_DEST
150 ok $? "MI test: expecting fail create session xsd validation"
151 is_command_success $OUTPUT_DEST true
152
153 OUTPUT_DEST=$DEVNULL
154 destroy_lttng_session $session_name
155 }
156
157 function test_destroy_session ()
158 {
159 local session_name=(
160 "testSession1"
161 "testSession2"
162 "testSession3")
163
164 OUTPUT_FILE="destroy_session.xml"
165
166 #Test build up
167 OUTPUT_DEST=$DEVNULL
168 for (( i = 0; i < 3; i++ )); do
169 create_lttng_session ${session_name[$i]} $OUTPUT_DIR
170 done
171
172 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
173 destroy_lttng_session ${session_name[0]}
174 $XML_VALIDATE $OUTPUT_DEST
175 ok $? "MI test: destroy session ${session_name[0]} xsd validation"
176
177 #Verify that we destroyed the good session
178 extract_xml $OUTPUT_DEST $XPATH_SESSION"/name/text()" result
179 test "$result" = "${session_name[0]}"
180 ok $? "Mi test: deleted session: $result expected: ${session_name[0]}"
181
182 #Destroy all and count:should be 2
183 destroy_lttng_sessions
184 $XML_VALIDATE $OUTPUT_DEST
185 ok $? "MI test: destroy all session xsd validation"
186
187 #Verify that we destroyed 2 sessions
188 extract_xml $OUTPUT_DEST $XPATH_SESSION"/name/text()" result
189 num=$(echo "$result" | wc -l)
190 test "$num" -eq "2"
191 ok $? "Mi test: $num / 2 sessions discovered"
192
193 #Verify that if no session is present command fail and mi report it.
194 destroy_lttng_session ${session_name[0]} 1
195 $XML_VALIDATE $OUTPUT_DEST
196 ok $? "MI test: failing destroy session ${session_name[0]} xsd validation"
197 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
198 test "$result" = "false"
199 ok $? "Mi test: destroy command on ${session_name[0]} failed as expected"
200
201 }
202
203 function test_list_sessions ()
204 {
205 local session_name=(
206 "testSession1"
207 "testSession2"
208 "testSession3")
209
210 OUTPUT_FILE="list_sessions.xml"
211
212 #Test buid up
213 OUTPUT_DEST=$DEVNULL
214 for (( i = 0; i < 3; i++ )); do
215 create_lttng_session ${session_name[$i]} $OUTPUT_DIR
216 done
217
218 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
219 list_lttng_with_opts
220 $XML_VALIDATE $OUTPUT_DEST
221 ok $? "Mi test: list sessions xsd validation"
222
223 #We should have 3 session
224 extract_xml $OUTPUT_DEST $XPATH_SESSION"/name/text()" result
225 num=$(echo "$result" | wc -l)
226 test "$num" -eq "3"
227 ok $? "Mi test: $num / 3 sessions discovered"
228
229 #Teardown
230 OUTPUT_DEST=$DEVNULL
231 destroy_lttng_sessions
232 }
233
234 function test_ust_channel ()
235 {
236 local session_name="testsession"
237 local channel_name=("channelUst0"
238 "channelUst1"
239 "channelUst2")
240
241 OUTPUT_FILE="ust_channel.xml"
242
243 #Test buil up
244 OUTPUT_DEST=$DEVNULL
245 create_lttng_session $session_name $OUTPUT_DIR
246
247 #Test the enable_channel command
248 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
249 enable_ust_lttng_channel $session_name ${channel_name[0]}
250 $XML_VALIDATE $OUTPUT_DEST
251 ok $? "Mi test: enable ust channel xsd validation"
252 is_command_success $OUTPUT_DEST false
253
254 #Expect the command to fail
255 enable_ust_lttng_channel $session_name ${channel_name[0]} true
256 $XML_VALIDATE $OUTPUT_DEST
257 ok $? "Mi test: fail enable ust channel xsd validation"
258 is_command_success $OUTPUT_DEST true
259
260 #Create two ust channel to test multiple disable
261 for (( i = 1; i < 3; i++ )); do
262 enable_ust_lttng_channel $session_name ${channel_name[$i]}
263 done
264
265 #Test the disable_channel command
266 disable_ust_lttng_channel $session_name ${channel_name[0]}
267 $XML_VALIDATE $OUTPUT_DEST
268 ok $? "Mi test: disable ust channel xsd validation"
269 is_command_success $OUTPUT_DEST false
270 #Check that we delete the good channel
271 extract_xml $OUTPUT_DEST $XPATH_ENABLE_CHANNEL_NAME result
272 test "$result" = "${channel_name[0]}"
273 ok $? "MI test: ${channel_name[0]} disabled"
274
275 #Test multiple disable_channel;
276 disable_ust_lttng_channel $session_name ${channel_name[1]},${channel_name[2]}
277 $XML_VALIDATE $OUTPUT_DEST
278 ok $? "Mi test: multiple disable ust channel xsd validation"
279 is_command_success $OUTPUT_DEST false
280
281 #Make sure we have two disabled channel
282 extract_xml $OUTPUT_DEST $XPATH_ENABLE_CHANNEL_NAME result
283 local num=$(echo "$result" | wc -l)
284 test "$num" = "2"
285 ok $? "Mi test: disabled ust channel $num/2"
286
287 #Teardown
288 OUTPUT_DEST=$DEVNULL
289 destroy_lttng_sessions
290
291 }
292
293 function test_ust_lttng_event ()
294 {
295 local session_name="testSession"
296 local channel_name="testChannel"
297 local event=("ev1" "ev2" "ev3")
298
299 OUTPUT_FILE="ust_event.xml"
300
301 #Test build up
302 OUTPUT_DEST=$DEVNULL
303 create_lttng_session $session_name $OUTPUT_DIR
304 enable_ust_lttng_channel $session_name $channel_name
305
306 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
307 #Test the enable event for ust domain
308 enable_ust_lttng_event $session_name ${event[0]} $channel_name
309 $XML_VALIDATE $OUTPUT_DEST
310 ok $? "Mi test: Enable_event for ust domain xsd validation"
311 is_command_success $OUTPUT_DEST false
312
313 #Try to reenable an enabled event. Should fail
314 enable_ust_lttng_event $session_name ${event[0]} $channel_name true
315 $XML_VALIDATE $OUTPUT_DEST
316 ok $? "Mi test: Fail enable_event for ust domain xsd validation"
317 is_command_success $OUTPUT_DEST true
318
319 #Enable multiple event including the last one command will fail
320 #But 2 events should success
321
322 #Nice little hack, create a string ev,ev,ev
323 #IFS stand for Internal field separator
324 #Event[*] print all the element inside the array with the IFS in between
325 concat_event=$( IFS=$','; echo "${event[*]}" )
326
327 enable_ust_lttng_event $session_name $concat_event $channel_name true
328 $XML_VALIDATE $OUTPUT_DEST
329 ok $? "Mi test: Multiple enable ust event with inside fail xsd validation"
330
331 #Check for 2 success = true et 1 false
332 extract_xml $OUTPUT_DEST $XPATH_ENABLE_EVENT_SUCCESS result
333 num_ocur=$(grep -o "true" <<< "$result" | wc -l)
334 test "$num_ocur" -eq "2"
335 ok $? "Mi test: Enabled event on failing enable command $num_ocur_true/2"
336
337 extract_xml $OUTPUT_DEST $XPATH_ENABLE_EVENT_SUCCESS result
338 num_ocur=$(grep -o "false" <<< "$result" | wc -l)
339 test "$num_ocur" -eq "1"
340 ok $? "Mi test: Enabled event on failing enable command $num_ocur_true/2"
341
342 #Disable the event
343 disable_ust_lttng_event $session_name ${event[0]} $channel_name
344 $XML_VALIDATE $OUTPUT_DEST
345 ok $? "Mi test: Disable ust event xsd validation"
346 is_command_success $OUTPUT_DEST false
347
348 #Disable the 3 event combined. Should pass
349 disable_ust_lttng_event $session_name $concat_event $channel_name
350 $XML_VALIDATE $OUTPUT_DEST
351 ok $? "Mi test: Disable multiple ust event xsd validation"
352 is_command_success $OUTPUT_DEST false
353
354 #Make sure we have 3 inner success
355 extract_xml $OUTPUT_DEST $XPATH_DISABLE_EVENT_SUCCESS result
356 num_ocur=$(grep -o "true" <<< "$result" | wc -l)
357 test "$num_ocur" -eq "3"
358 ok $? "Mi test: Disable multiple ust event success $num_ocur/3"
359
360 #Teardown
361 OUTPUT_DEST=$DEVNULL
362 destroy_lttng_sessions
363 }
364
365 function test_list_channel ()
366 {
367 local session_name="testSession"
368 local channel_name="testChannel"
369 local event=("ev1" "ev2" "ev3")
370
371 OUTPUT_FILE="list_channel.xml"
372
373 #Test buid up
374 OUTPUT_DEST=$DEVNULL
375 create_lttng_session $session_name $OUTPUT_DIR
376 enable_ust_lttng_channel $session_name $channel_name
377
378 #Enable ust and jul events
379 concat_event=$( IFS=$','; echo "${event[*]}" )
380 enable_ust_lttng_event $session_name $concat_event $channel_name
381
382 #Begin testing
383 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
384 list_lttng_with_opts "$session_name -c $channel_name"
385 $XML_VALIDATE $OUTPUT_DEST
386 ok $? "Mi test: list channel xsd validation"
387
388 #Expect 1 domain: UST
389 extract_xml $OUTPUT_DEST $XPATH_LIST_DOMAIN"/type/text()" result
390 num=$(echo "$result" | wc -l)
391 test "$num" -eq "1"
392 ok $? "Mi test: $num / 1 domains discovered"
393
394 #Expect 1 channel: test
395 extract_xml $OUTPUT_DEST $XPATH_LIST_CHANNEL"/name/text()" result
396 num=$(echo "$result" | wc -l)
397 test "$num" -eq "1"
398 ok $? "Mi test: $num / 1 channel discovered"
399
400 test "$result" = "$channel_name"
401 ok $? "Mi test: expected channel: $channel_name found: $result"
402
403 #Add a channel and make sure we have 2 channel now
404 OUTPUT_DEST=$DEVNULL
405 enable_ust_lttng_channel $session_name $channel_name"a"
406
407 #Teardown
408 OUTPUT_DEST=$DEVNULL
409 destroy_lttng_sessions
410 }
411
412 function test_list_domain ()
413 {
414 local session_name="testSession"
415 local channel_name="testChannel"
416 local event=("ev1" "ev2" "ev3")
417
418 OUTPUT_FILE="list_domain.xml"
419
420 #Test buid up
421 OUTPUT_DEST=$DEVNULL
422 create_lttng_session $session_name $OUTPUT_DIR
423 enable_ust_lttng_channel $session_name $channel_name
424
425 #Enable ust and jul events
426 concat_event=$( IFS=$','; echo "${event[*]}" )
427 enable_ust_lttng_event $session_name $concat_event $channel_name
428 enable_jul_lttng_event $session_name $concat_event $channel_name
429
430 #Begin testing
431 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
432 list_lttng_with_opts "$session_name -d"
433 $XML_VALIDATE $OUTPUT_DEST
434 ok $? "Mi test: list domain xsd validation"
435
436 #Expect 2 domain: Jul and UST
437 extract_xml $OUTPUT_DEST $XPATH_LIST_DOMAIN"/type/text()" result
438 num=$(echo "$result" | wc -l)
439 test "$num" -eq "2"
440 ok $? "Mi test: $num / 2 domains discovered"
441
442 #Test for valid value
443 if [[ "$result" = *"JUL"* ]]; then
444 pass "Mi test: domains Jul is present"
445 else
446 fail "Mi test: domains Jul is absent"
447 fi
448
449 if [[ "$result" = *"UST"* ]]; then
450 pass "Mi test: domains UST is present"
451 else
452 fail "Mi test: domains UST is absent"
453 fi
454
455 #Teardown
456 OUTPUT_DEST=$DEVNULL
457 destroy_lttng_sessions
458 }
459
460 function test_list_session ()
461 {
462 local session_name="testSession"
463 local channel_name="testChannel"
464 local event=("ev1" "ev2" "ev3")
465
466 OUTPUT_FILE="list_session.xml"
467
468 #Test buid up
469 OUTPUT_DEST=$DEVNULL
470 create_lttng_session $session_name $OUTPUT_DIR
471 enable_ust_lttng_channel $session_name $channel_name
472
473 #Enable ust and jul events
474 concat_event=$( IFS=$','; echo "${event[*]}" )
475 enable_ust_lttng_event $session_name $concat_event $channel_name
476 enable_jul_lttng_event $session_name $concat_event $channel_name
477
478 #Begin testing
479 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
480 list_lttng_with_opts $session_name
481 $XML_VALIDATE $OUTPUT_DEST
482 ok $? "Mi test: list session xsd validation"
483
484 #Expect 2 domain: Jul and UST
485 extract_xml $OUTPUT_DEST $XPATH_LIST_DOMAIN"/type/text()" result
486 num=$(echo "$result" | wc -l)
487 test "$num" -eq "2"
488 ok $? "Mi test: $num / 2 domains discovered"
489
490 #Expect 2 channel: test and lttng_jul_event
491 extract_xml $OUTPUT_DEST $XPATH_LIST_CHANNEL"/name/text()" result
492 num=$(echo "$result" | wc -l)
493 test "$num" -eq "2"
494 ok $? "Mi test: $num / 2 channel discovered"
495
496 #Teardown
497 OUTPUT_DEST=$DEVNULL
498 destroy_lttng_sessions
499 }
500
501 function test_list_ust_event ()
502 {
503 OUTPUT_FILE="list_ust_event.xml"
504
505 #Test buid up
506 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
507
508 #Begin testing
509 $TESTAPP_BIN $NR_USEC_WAIT & 2>/dev/null
510 list_lttng_with_opts "-u -f"
511 $XML_VALIDATE $OUTPUT_DEST
512 ok $? "Mi test: list ust event xsd validation"
513
514 #Extract events 3 events should be present
515 extract_xml $OUTPUT_DEST "$XPATH_LIST_UST_EVENT""/name/text()" result
516 num=$(echo "$result" | wc -l)
517 test "$num" -eq "3"
518 ok $? "Mi test: $num / 3 ust events discovered"
519
520 #Extract field from tp:tptest event. Expect 12
521 extract_xml $OUTPUT_DEST "$XPATH_LIST_UST_EVENT""[./name = 'tp:tptest']/event_fields/event_field/name/text()" result
522 num=$(echo "$result" | wc -l)
523 test "$num" -eq "12"
524 ok $? "Mi test: $num / 12 ust event fields discovered"
525
526 #Wait for last forked process
527 wait $!
528
529 }
530
531 function test_start_stop () {
532 local session_name="testStartStopSession"
533 local channel_name="startStopChannel"
534
535 OUTPUT_FILE="list_start_stop.xml"
536
537 #Test buid up
538 OUTPUT_DEST=$DEVNULL
539 create_lttng_session $session_name $OUTPUT_DIR
540
541 #Test fail command
542 #No channel enable start command should return element success false
543 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
544 start_lttng_tracing $session_name 1
545 $XML_VALIDATE $OUTPUT_DEST
546 ok $? "Mi test: failed start xsd validation"
547
548 #Expect a false element
549 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
550 test "$result" = "false"
551 ok $? "Mi test: mi report failure on start command as expected"
552
553 #Enable a channel to test success
554 OUTPUT_DEST=$DEVNULL
555 enable_ust_lttng_channel $session_name $channel_name
556
557 #Start tracing
558 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
559 start_lttng_tracing $session_name
560 $XML_VALIDATE $OUTPUT_DEST
561 ok $? "Mi test: start xsd validation"
562
563 #Expect a true element
564 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
565 test "$result" = "true"
566 ok $? "Mi test: mi report success on start command as expected"
567
568 #Extract session name from xml
569 extract_xml $OUTPUT_DEST $XPATH_SESSION"/name/text()" result
570 test "$result" = "$session_name"
571 ok $? "Mi test: started $session_name"
572
573 #Extract enabled expect true
574 extract_xml $OUTPUT_DEST $XPATH_SESSION"/enabled/text()" result
575 test "$result" = "true"
576 ok $? "Mi test: enabled element : $result expected: true"
577
578 #Test stop command
579 stop_lttng_tracing $session_name
580 $XML_VALIDATE $OUTPUT_DEST
581 ok $? "Mi test: stop xsd validation"
582
583 #Extract session name from xml
584 extract_xml $OUTPUT_DEST $XPATH_SESSION"/name/text()" result
585 test "$result" = "$session_name"
586 ok $? "Mi test: stoped $session_name"
587
588 #Extract enabled expect false
589 extract_xml $OUTPUT_DEST $XPATH_SESSION"/enabled/text()" result
590 test "$result" = "false"
591 ok $? "Mi test: enabled element : $result expected: false"
592
593 #Test failing stop command
594 stop_lttng_tracing $session_name 1
595 $XML_VALIDATE $OUTPUT_DEST
596 ok $? "Mi test: failed stop xsd validation"
597
598 #Expect a false element
599 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
600 test "$result" = "false"
601 ok $? "Mi test: mi report failure on start command as expected"
602
603 #Teardown
604 OUTPUT_DEST=$DEVNULL
605 destroy_lttng_sessions
606
607 }
608
609 function test_snapshot () {
610 local session_name="testSnapshotAdd"
611 local snapshot_path="$OUTPUT_DIR/snapshotoutput"
612 OUTPUT_FILE="snapshot.xml"
613
614
615 #Test buid up
616 OUTPUT_DEST=$DEVNULL
617 create_lttng_session_no_output $session_name
618
619 #Test fail command
620 #No channel enable start command should return element success false
621 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
622 lttng_snapshot_add_output $session_name $snapshot_path
623 $XML_VALIDATE $OUTPUT_DEST
624 ok $? "Mi test: snapshot xsd validation"
625
626 #Expect a true element
627 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
628 test "$result" = "true"
629 ok $? "Mi test: add snapshot is a success"
630
631 #Get data
632 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/snapshot/session_name/text()" result
633 test "$result" = "$session_name"
634 ok $? "Mi test: added snapshot for: $result expected $session_name"
635
636 #Get name of generated output and id
637 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/snapshot/name/text()" snapshot_name
638 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/snapshot/id/text()" snapshot_id
639
640 #Test list output
641 lttng_snapshot_list $session_name
642 $XML_VALIDATE $OUTPUT_DEST
643 ok $? "Mi test: snapshot list xsd validation"
644
645 #Expect a true element
646 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
647 test "$result" = "true"
648 ok $? "Mi test: add snapshot is a success"
649
650 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_LIST""/session[./name ='$session_name']/snapshots/snapshot/name/text()" result
651 test "$result" = "$snapshot_name"
652 ok $? "Mi test: snapshot list extracted snapshot: $result expected: $snapshot_name"
653
654 #Test del output
655 lttng_snapshot_del_output $session_name $snapshot_id
656 $XML_VALIDATE $OUTPUT_DEST
657 ok $? "Mi test: snapshot delete xsd validation"
658
659 #Success ?
660 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
661 test "$result" = "true"
662 ok $? "Mi test: del snapshot is a success"
663
664 #Test data
665 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/snapshot/id/text()" result
666 test "$result" = "$snapshot_id"
667 ok $? "Mi test: snapshot del extracted snapshot id: $result expected: $snapshot_id"
668
669 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/snapshot/session_name/text()" result
670 test "$result" = "$session_name"
671 ok $? "Mi test: snapshot del extracted snapshot id: $result expected: $session_name"
672
673 #Test fail on delete command
674 lttng_snapshot_del_output $session_name $snapshot_id 1
675 $XML_VALIDATE $OUTPUT_DEST
676 ok $? "Mi test: snapshot delete xsd validation"
677
678 #Success ?
679 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
680 test "$result" = "false"
681 ok $? "Mi test: del snapshot is a success"
682
683 OUTPUT_DEST=$DEVNULL
684 destroy_lttng_sessions
685 }
686
687 start_lttng_sessiond $FOO_LOAD_DIR
688 TESTS=(
689 test_version
690 test_create_session
691 test_destroy_session
692 test_list_sessions
693 test_ust_channel
694 test_ust_lttng_event
695 test_list_channel
696 test_list_domain
697 test_list_session
698 test_list_ust_event
699 test_start_stop
700 test_snapshot
701 )
702
703
704 echo $OUTPUT_DIR
705 for fct_test in ${TESTS[@]};
706 do
707 ${fct_test}
708 if [ $? -ne 0 ]; then
709 break;
710 fi
711 done
712 rm -rf $OUTPUT_DIR
713
714 OUTPUT_DEST=/dev/null 2>&1
715 stop_lttng_sessiond
This page took 0.080247 seconds and 4 git commands to generate.