Fix: test_mi test
[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=0
31 NR_ITER=10000
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 declaration 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_ok $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_fail $session_name $OUTPUT_DIR
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_ok $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_ok ${session_name[$i]} $OUTPUT_DIR
170 done
171
172 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
173 destroy_lttng_session_ok ${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_fail ${session_name[0]}
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_ok ${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_ok $session_name $OUTPUT_DIR
246
247 #Test the enable_channel command
248 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
249 enable_ust_lttng_channel_ok $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_fail $session_name ${channel_name[0]}
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_ok $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_ok $session_name $OUTPUT_DIR
304 enable_ust_lttng_channel_ok $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_ok $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_fail $session_name ${event[0]} $channel_name
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_fail $session_name $concat_event $channel_name
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 and 1 success = 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_ok $session_name $OUTPUT_DIR
376 enable_ust_lttng_channel_ok $session_name $channel_name
377
378 #Enable ust and jul events
379 concat_event=$( IFS=$','; echo "${event[*]}" )
380 enable_ust_lttng_event_ok $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_ok $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_ok $session_name $OUTPUT_DIR
423 enable_ust_lttng_channel_ok $session_name $channel_name
424
425 #Enable ust and jul events
426 concat_event=$( IFS=$','; echo "${event[*]}" )
427 enable_ust_lttng_event_ok $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_ok $session_name $OUTPUT_DIR
471 enable_ust_lttng_channel_ok $session_name $channel_name
472
473 #Enable ust and jul events
474 concat_event=$( IFS=$','; echo "${event[*]}" )
475 enable_ust_lttng_event_ok $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 local file_sync_after_first=$(mktemp -u)
504 local file_sync_before_last=$(mktemp -u)
505
506 OUTPUT_FILE="list_ust_event.xml"
507
508 #Test buid up
509 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
510
511 #Begin testing
512 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} & 2>/dev/null
513
514 while [ ! -f "${file_sync_after_first}" ]; do
515 sleep 0.5
516 done
517
518 list_lttng_with_opts "-u -f"
519
520 touch ${file_sync_before_last}
521
522 $XML_VALIDATE $OUTPUT_DEST
523 ok $? "Mi test: list ust event xsd validation"
524
525 #Extract events
526 extract_xml $OUTPUT_DEST "$XPATH_LIST_UST_EVENT""/name/text()" result
527 num=$(echo "$result" | wc -l)
528
529 #Since the number of events is prone to change we only look for >= from a
530 #base number. An alternative would be to look for each events but this
531 #is complicated for nothing.
532 test "$num" -ge "5"
533 ok $? "Mi test: $num / 5 ust events discovered"
534
535 #Extract field from tp:tptest event. Expect >= to 12 because number of
536 #field is prone to change.
537 extract_xml $OUTPUT_DEST "$XPATH_LIST_UST_EVENT""[./name = 'tp:tptest']/event_fields/event_field/name/text()" result
538 num=$(echo "$result" | wc -l)
539 test "$num" -ge "12"
540 ok $? "Mi test: $num / 12 ust event fields discovered"
541
542 #Wait for all background processes
543 wait
544
545 rm -f ${file_sync_after_first}
546 rm -f ${file_sync_before_last}
547 }
548
549 function test_start_stop () {
550 local session_name="testStartStopSession"
551 local channel_name="startStopChannel"
552
553 OUTPUT_FILE="list_start_stop.xml"
554
555 #Test buid up
556 OUTPUT_DEST=$DEVNULL
557 create_lttng_session_ok $session_name $OUTPUT_DIR
558
559 #Test fail command
560 #No channel enable start command should return element success false
561 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
562 start_lttng_tracing_fail $session_name
563 $XML_VALIDATE $OUTPUT_DEST
564 ok $? "Mi test: failed start xsd validation"
565
566 #Expect a false element
567 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
568 test "$result" = "false"
569 ok $? "Mi test: mi report failure on start command as expected"
570
571 #Enable a channel to test success
572 OUTPUT_DEST=$DEVNULL
573 enable_ust_lttng_channel_ok $session_name $channel_name
574
575 #Start tracing
576 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
577 start_lttng_tracing_ok $session_name
578 $XML_VALIDATE $OUTPUT_DEST
579 ok $? "Mi test: start xsd validation"
580
581 #Expect a true element
582 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
583 test "$result" = "true"
584 ok $? "Mi test: mi report success on start command as expected"
585
586 #Extract session name from xml
587 extract_xml $OUTPUT_DEST $XPATH_SESSION"/name/text()" result
588 test "$result" = "$session_name"
589 ok $? "Mi test: started $session_name"
590
591 #Extract enabled expect true
592 extract_xml $OUTPUT_DEST $XPATH_SESSION"/enabled/text()" result
593 test "$result" = "true"
594 ok $? "Mi test: enabled element : $result expected: true"
595
596 #Test stop command
597 stop_lttng_tracing_ok $session_name
598 $XML_VALIDATE $OUTPUT_DEST
599 ok $? "Mi test: stop xsd validation"
600
601 #Extract session name from xml
602 extract_xml $OUTPUT_DEST $XPATH_SESSION"/name/text()" result
603 test "$result" = "$session_name"
604 ok $? "Mi test: stoped $session_name"
605
606 #Extract enabled expect false
607 extract_xml $OUTPUT_DEST $XPATH_SESSION"/enabled/text()" result
608 test "$result" = "false"
609 ok $? "Mi test: enabled element : $result expected: false"
610
611 #Test failing stop command
612 stop_lttng_tracing_fail $session_name
613 $XML_VALIDATE $OUTPUT_DEST
614 ok $? "Mi test: failed stop xsd validation"
615
616 #Expect a false element
617 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
618 test "$result" = "false"
619 ok $? "Mi test: mi report failure on start command as expected"
620
621 #Teardown
622 OUTPUT_DEST=$DEVNULL
623 destroy_lttng_sessions
624 }
625
626 function test_snapshot () {
627 local session_name="testSnapshotAdd"
628 local snapshot_path="$OUTPUT_DIR/snapshotoutput"
629 OUTPUT_FILE="snapshot.xml"
630
631
632 #Test buid up
633 OUTPUT_DEST=$DEVNULL
634 create_lttng_session_no_output $session_name
635
636 #Test fail command
637 #No channel enable start command should return element success false
638 OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE
639 lttng_snapshot_add_output_ok $session_name $snapshot_path
640 $XML_VALIDATE $OUTPUT_DEST
641 ok $? "Mi test: snapshot xsd validation"
642
643 #Expect a true element
644 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
645 test "$result" = "true"
646 ok $? "Mi test: add snapshot is a success"
647
648 #Get data
649 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/snapshot/session_name/text()" result
650 test "$result" = "$session_name"
651 ok $? "Mi test: added snapshot for: $result expected $session_name"
652
653 #Get name of generated output and id
654 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/snapshot/name/text()" snapshot_name
655 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/snapshot/id/text()" snapshot_id
656
657 #Test list output
658 lttng_snapshot_list $session_name
659 $XML_VALIDATE $OUTPUT_DEST
660 ok $? "Mi test: snapshot list xsd validation"
661
662 #Expect a true element
663 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
664 test "$result" = "true"
665 ok $? "Mi test: add snapshot is a success"
666
667 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_LIST""/session[./name ='$session_name']/snapshots/snapshot/name/text()" result
668 test "$result" = "$snapshot_name"
669 ok $? "Mi test: snapshot list extracted snapshot: $result expected: $snapshot_name"
670
671 #Test del output
672 lttng_snapshot_del_output_ok $session_name $snapshot_id
673 $XML_VALIDATE $OUTPUT_DEST
674 ok $? "Mi test: snapshot delete xsd validation"
675
676 #Success ?
677 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
678 test "$result" = "true"
679 ok $? "Mi test: del snapshot is a success"
680
681 #Test data
682 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/snapshot/id/text()" result
683 test "$result" = "$snapshot_id"
684 ok $? "Mi test: snapshot del extracted snapshot id: $result expected: $snapshot_id"
685
686 extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/snapshot/session_name/text()" result
687 test "$result" = "$session_name"
688 ok $? "Mi test: snapshot del extracted snapshot id: $result expected: $session_name"
689
690 #Test fail on delete command
691 lttng_snapshot_del_output_fail $session_name $snapshot_id
692 $XML_VALIDATE $OUTPUT_DEST
693 ok $? "Mi test: snapshot delete xsd validation"
694
695 #Success ?
696 extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result
697 test "$result" = "false"
698 ok $? "Mi test: del snapshot is a success"
699
700 OUTPUT_DEST=$DEVNULL
701 destroy_lttng_sessions
702 }
703
704 start_lttng_sessiond $FOO_LOAD_DIR
705 TESTS=(
706 test_version
707 test_create_session
708 test_destroy_session
709 test_list_sessions
710 test_ust_channel
711 test_ust_lttng_event
712 test_list_channel
713 test_list_domain
714 test_list_session
715 test_list_ust_event
716 test_start_stop
717 test_snapshot
718 )
719
720
721 echo $OUTPUT_DIR
722 for fct_test in ${TESTS[@]};
723 do
724 ${fct_test}
725 if [ $? -ne 0 ]; then
726 break;
727 fi
728 done
729 rm -rf $OUTPUT_DIR
730
731 OUTPUT_DEST=/dev/null 2>&1
732 stop_lttng_sessiond
This page took 0.07141 seconds and 4 git commands to generate.