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