Commit | Line | Data |
---|---|---|
312dabc3 JRJ |
1 | #!/bin/bash |
2 | # | |
9d16b343 | 3 | # Copyright (C) 2014 Jonathan Rajotte <jonathan.r.julien@gmail.com> |
312dabc3 | 4 | # |
9d16b343 | 5 | # SPDX-License-Identifier: LGPL-2.1-only |
312dabc3 JRJ |
6 | |
7 | TEST_DESC="Machine interface testing" | |
8 | ||
9 | CURDIR=$(dirname $0)/ | |
10 | TESTDIR=$CURDIR/../../../ | |
01fac814 | 11 | XSD_PATH=$TESTDIR/../src/common/mi-lttng-4.0.xsd |
312dabc3 | 12 | |
01513c3e JRJ |
13 | #Test app for ust event |
14 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
15 | TESTAPP_NAME="gen-ust-events" | |
16 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
1c240f7e MD |
17 | NR_USEC_WAIT=0 |
18 | NR_ITER=10000 | |
312dabc3 JRJ |
19 | |
20 | #Temp file output | |
01513c3e | 21 | OUTPUT_DIR=$(mktemp -d) |
151c0584 | 22 | SESSIOND_LOAD_DIR=$(mktemp -d) |
312dabc3 JRJ |
23 | OUTPUT_FILE="default.xml" |
24 | ||
25 | #Path to custom xml utilities | |
26 | XML_VALIDATE="$CURDIR/validate_xml $XSD_PATH" | |
27 | XML_EXTRACT="$CURDIR/extract_xml" | |
e83a8bdb | 28 | XML_NODE_CHECK="$CURDIR/extract_xml -e" |
312dabc3 | 29 | |
41af1adf JG |
30 | XPATH_CMD_OUTPUT="//lttng:command/lttng:output" |
31 | XPATH_COMMAND_SUCCESS="/lttng:command/lttng:success/text()" | |
32 | XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session" | |
33 | XPATH_ENABLE_CHANNEL_NAME="$XPATH_CMD_OUTPUT/lttng:channels/lttng:channel/lttng:name/text()" | |
34 | XPATH_ENABLE_EVENT_SUCCESS="$XPATH_CMD_OUTPUT/lttng:events/lttng:event/lttng:success/text()" | |
35 | XPATH_DISABLE_EVENT_SUCCESS="$XPATH_CMD_OUTPUT/lttng:channel/lttng:events/lttng:event/lttng:success/text()" | |
36 | XPATH_LIST_DOMAIN="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain" | |
37 | XPATH_LIST_CHANNEL="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel" | |
38 | XPATH_LIST_UST_EVENT="$XPATH_CMD_OUTPUT/lttng:domains/lttng:domain[./lttng:type ='UST']/lttng:pids/lttng:pid/lttng:events/lttng:event" | |
39 | XPATH_SNAPSHOT_ADD_SNAPSHOT="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'add-output']/lttng:output" | |
40 | XPATH_SNAPSHOT_LIST="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'list-output']/lttng:output" | |
41 | XPATH_SNAPSHOT_DEL="$XPATH_CMD_OUTPUT/lttng:snapshot_action[./lttng:name = 'del-output']/lttng:output" | |
159b042f JG |
42 | XPATH_TRACK_UNTRACK_VPID="$XPATH_CMD_OUTPUT/lttng:process_attr_trackers/lttng:vpid_process_attr_tracker/lttng:process_attr_values/lttng:vpid/lttng:type" |
43 | XPATH_VPID_TRACKER="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vpid_process_attr_tracker" | |
312dabc3 JRJ |
44 | |
45 | DEVNULL=/dev/null 2>&1 | |
46 | ||
47 | DIR=$(readlink -f $TESTDIR) | |
48 | ||
5ee26199 | 49 | NUM_TESTS=246 |
312dabc3 JRJ |
50 | |
51 | source $TESTDIR/utils/utils.sh | |
52 | ||
53 | #Overwrite the lttng_bin to get mi output | |
54 | LTTNG_BIN="lttng --mi xml" | |
55 | ||
6bad3253 | 56 | #Global declaration for simplification |
312dabc3 JRJ |
57 | LTTNG=$TESTDIR/../src/bin/lttng/$LTTNG_BIN |
58 | ||
59 | #Overwrite the default output for utils.sh command | |
60 | ||
61 | #MUST set TESTDIR before calling those functions | |
62 | plan_tests $NUM_TESTS | |
63 | ||
64 | print_test_banner "$TEST_DESC" | |
65 | ||
66 | function extract_xml () | |
67 | { | |
68 | local xml=$1 | |
69 | local xpath=$2 | |
70 | local __result=$3 | |
01513c3e JRJ |
71 | local output |
72 | output=$($XML_EXTRACT $xml "$xpath") | |
312dabc3 JRJ |
73 | ok $? "Extraction of xpath $xpath" |
74 | eval $__result="'$output'" | |
75 | } | |
76 | ||
e83a8bdb JR |
77 | function node_check_xml () |
78 | { | |
79 | local xml=$1 | |
80 | local xpath=$2 | |
81 | local __result=$3 | |
82 | local output | |
83 | output=$($XML_NODE_CHECK $xml "$xpath") | |
84 | ok $? "Check of node existence with xpath $xpath" | |
85 | eval $__result="'$output'" | |
86 | } | |
87 | ||
312dabc3 JRJ |
88 | # Arg1 is path to xml file |
89 | # Arg2: | |
90 | # is true if we expected the success element to be false | |
91 | # else | |
92 | # passe false | |
93 | ||
94 | function is_command_success () | |
95 | { | |
96 | local xml=$1 | |
97 | local expect_false=$2 | |
98 | ||
99 | local xpath=$XPATH_COMMAND_SUCCESS | |
100 | ||
41af1adf | 101 | echo $xml |
312dabc3 JRJ |
102 | #Extract the success element |
103 | #expect false | |
104 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
01513c3e | 105 | if [[ $expect_false = "true" ]]; then |
312dabc3 JRJ |
106 | if [[ $result ]]; then |
107 | pass "Mi test: $xml command failed as expected" | |
108 | else | |
109 | fail "Mi test: $xml command did not fail as expected" | |
110 | fi | |
111 | else | |
112 | if [[ $result ]]; then | |
312dabc3 | 113 | pass "Mi test: $xml command success" |
01513c3e JRJ |
114 | else |
115 | fail "Mi test: $xml command failed" | |
312dabc3 JRJ |
116 | fi |
117 | fi | |
118 | } | |
119 | ||
120 | function mi_print_version () | |
121 | { | |
312dabc3 | 122 | local output_path=$1 |
047adf91 | 123 | local opt=$2 |
312dabc3 | 124 | |
047adf91 | 125 | $LTTNG version $opt > $output_path |
312dabc3 JRJ |
126 | ok $? "MI test: Lttng version" |
127 | ||
128 | } | |
129 | ||
130 | function test_version () | |
131 | { | |
132 | OUTPUT_FILE="version.xml" | |
133 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
134 | mi_print_version $OUTPUT_DEST | |
135 | $XML_VALIDATE $OUTPUT_DEST | |
136 | ok $? "MI test: Version xsd validation" | |
137 | } | |
138 | ||
139 | function test_create_session () | |
140 | { | |
141 | local session_name="testSession" | |
142 | ||
143 | OUTPUT_FILE="create_session.xml" | |
144 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
bf6ae429 | 145 | create_lttng_session_ok $session_name $OUTPUT_DIR |
312dabc3 JRJ |
146 | $XML_VALIDATE $OUTPUT_DEST |
147 | ok $? "MI test: create session xsd validation" | |
148 | ||
149 | #try to recreate a session. Expecting it to fail | |
bf6ae429 | 150 | create_lttng_session_fail $session_name $OUTPUT_DIR |
312dabc3 JRJ |
151 | $XML_VALIDATE $OUTPUT_DEST |
152 | ok $? "MI test: expecting fail create session xsd validation" | |
153 | is_command_success $OUTPUT_DEST true | |
154 | ||
155 | OUTPUT_DEST=$DEVNULL | |
67b4c664 | 156 | destroy_lttng_session_ok $session_name |
312dabc3 JRJ |
157 | } |
158 | ||
159 | function test_destroy_session () | |
160 | { | |
161 | local session_name=( | |
162 | "testSession1" | |
163 | "testSession2" | |
164 | "testSession3") | |
165 | ||
166 | OUTPUT_FILE="destroy_session.xml" | |
167 | ||
168 | #Test build up | |
169 | OUTPUT_DEST=$DEVNULL | |
170 | for (( i = 0; i < 3; i++ )); do | |
bf6ae429 | 171 | create_lttng_session_ok ${session_name[$i]} $OUTPUT_DIR |
312dabc3 JRJ |
172 | done |
173 | ||
174 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
67b4c664 | 175 | destroy_lttng_session_ok ${session_name[0]} |
312dabc3 JRJ |
176 | $XML_VALIDATE $OUTPUT_DEST |
177 | ok $? "MI test: destroy session ${session_name[0]} xsd validation" | |
178 | ||
179 | #Verify that we destroyed the good session | |
41af1adf | 180 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result |
01513c3e JRJ |
181 | test "$result" = "${session_name[0]}" |
182 | ok $? "Mi test: deleted session: $result expected: ${session_name[0]}" | |
312dabc3 JRJ |
183 | |
184 | #Destroy all and count:should be 2 | |
185 | destroy_lttng_sessions | |
186 | $XML_VALIDATE $OUTPUT_DEST | |
187 | ok $? "MI test: destroy all session xsd validation" | |
188 | ||
189 | #Verify that we destroyed 2 sessions | |
41af1adf | 190 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result |
312dabc3 JRJ |
191 | num=$(echo "$result" | wc -l) |
192 | test "$num" -eq "2" | |
193 | ok $? "Mi test: $num / 2 sessions discovered" | |
01513c3e JRJ |
194 | |
195 | #Verify that if no session is present command fail and mi report it. | |
67b4c664 | 196 | destroy_lttng_session_fail ${session_name[0]} |
01513c3e JRJ |
197 | $XML_VALIDATE $OUTPUT_DEST |
198 | ok $? "MI test: failing destroy session ${session_name[0]} xsd validation" | |
199 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
200 | test "$result" = "false" | |
201 | ok $? "Mi test: destroy command on ${session_name[0]} failed as expected" | |
202 | ||
312dabc3 JRJ |
203 | } |
204 | ||
205 | function test_list_sessions () | |
206 | { | |
207 | local session_name=( | |
208 | "testSession1" | |
209 | "testSession2" | |
210 | "testSession3") | |
211 | ||
212 | OUTPUT_FILE="list_sessions.xml" | |
213 | ||
214 | #Test buid up | |
215 | OUTPUT_DEST=$DEVNULL | |
216 | for (( i = 0; i < 3; i++ )); do | |
bf6ae429 | 217 | create_lttng_session_ok ${session_name[$i]} $OUTPUT_DIR |
312dabc3 JRJ |
218 | done |
219 | ||
220 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
221 | list_lttng_with_opts | |
222 | $XML_VALIDATE $OUTPUT_DEST | |
01513c3e | 223 | ok $? "Mi test: list sessions xsd validation" |
312dabc3 JRJ |
224 | |
225 | #We should have 3 session | |
41af1adf | 226 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result |
312dabc3 JRJ |
227 | num=$(echo "$result" | wc -l) |
228 | test "$num" -eq "3" | |
229 | ok $? "Mi test: $num / 3 sessions discovered" | |
230 | ||
231 | #Teardown | |
232 | OUTPUT_DEST=$DEVNULL | |
233 | destroy_lttng_sessions | |
234 | } | |
235 | ||
c764163f JR |
236 | function test_list_session_long_path () |
237 | { | |
238 | local session_name="session_long_path" | |
239 | ||
240 | output_basedir=$OUTPUT_DIR/$(randstring 254 0) | |
241 | mkdir -p ${output_basedir} | |
242 | ||
243 | OUTPUT_FILE="list_sessions.xml" | |
244 | ||
245 | #Test build up | |
246 | OUTPUT_DEST=$DEVNULL | |
247 | create_lttng_session_ok $session_name ${output_basedir} | |
248 | ||
249 | OUTPUT_DEST=${output_basedir}/$OUTPUT_FILE | |
250 | list_lttng_with_opts | |
251 | $XML_VALIDATE $OUTPUT_DEST | |
252 | ok $? "Mi test: list session with long path xsd validation" | |
253 | ||
254 | #Teardown | |
255 | OUTPUT_DEST=$DEVNULL | |
256 | destroy_lttng_sessions | |
257 | } | |
312dabc3 JRJ |
258 | function test_ust_channel () |
259 | { | |
260 | local session_name="testsession" | |
261 | local channel_name=("channelUst0" | |
262 | "channelUst1" | |
263 | "channelUst2") | |
264 | ||
265 | OUTPUT_FILE="ust_channel.xml" | |
266 | ||
267 | #Test buil up | |
268 | OUTPUT_DEST=$DEVNULL | |
bf6ae429 | 269 | create_lttng_session_ok $session_name $OUTPUT_DIR |
312dabc3 JRJ |
270 | |
271 | #Test the enable_channel command | |
272 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
827caf52 | 273 | enable_ust_lttng_channel_ok $session_name ${channel_name[0]} |
312dabc3 JRJ |
274 | $XML_VALIDATE $OUTPUT_DEST |
275 | ok $? "Mi test: enable ust channel xsd validation" | |
01513c3e | 276 | is_command_success $OUTPUT_DEST false |
312dabc3 JRJ |
277 | |
278 | #Expect the command to fail | |
827caf52 | 279 | enable_ust_lttng_channel_fail $session_name ${channel_name[0]} |
312dabc3 JRJ |
280 | $XML_VALIDATE $OUTPUT_DEST |
281 | ok $? "Mi test: fail enable ust channel xsd validation" | |
01513c3e | 282 | is_command_success $OUTPUT_DEST true |
312dabc3 JRJ |
283 | |
284 | #Create two ust channel to test multiple disable | |
285 | for (( i = 1; i < 3; i++ )); do | |
827caf52 | 286 | enable_ust_lttng_channel_ok $session_name ${channel_name[$i]} |
312dabc3 JRJ |
287 | done |
288 | ||
289 | #Test the disable_channel command | |
290 | disable_ust_lttng_channel $session_name ${channel_name[0]} | |
291 | $XML_VALIDATE $OUTPUT_DEST | |
292 | ok $? "Mi test: disable ust channel xsd validation" | |
01513c3e | 293 | is_command_success $OUTPUT_DEST false |
312dabc3 JRJ |
294 | #Check that we delete the good channel |
295 | extract_xml $OUTPUT_DEST $XPATH_ENABLE_CHANNEL_NAME result | |
01513c3e | 296 | test "$result" = "${channel_name[0]}" |
312dabc3 JRJ |
297 | ok $? "MI test: ${channel_name[0]} disabled" |
298 | ||
299 | #Test multiple disable_channel; | |
300 | disable_ust_lttng_channel $session_name ${channel_name[1]},${channel_name[2]} | |
301 | $XML_VALIDATE $OUTPUT_DEST | |
302 | ok $? "Mi test: multiple disable ust channel xsd validation" | |
01513c3e | 303 | is_command_success $OUTPUT_DEST false |
312dabc3 JRJ |
304 | |
305 | #Make sure we have two disabled channel | |
306 | extract_xml $OUTPUT_DEST $XPATH_ENABLE_CHANNEL_NAME result | |
307 | local num=$(echo "$result" | wc -l) | |
01513c3e | 308 | test "$num" = "2" |
312dabc3 JRJ |
309 | ok $? "Mi test: disabled ust channel $num/2" |
310 | ||
311 | #Teardown | |
312 | OUTPUT_DEST=$DEVNULL | |
313 | destroy_lttng_sessions | |
314 | ||
315 | } | |
316 | ||
01513c3e JRJ |
317 | function test_ust_lttng_event () |
318 | { | |
319 | local session_name="testSession" | |
320 | local channel_name="testChannel" | |
321 | local event=("ev1" "ev2" "ev3") | |
322 | ||
323 | OUTPUT_FILE="ust_event.xml" | |
324 | ||
325 | #Test build up | |
326 | OUTPUT_DEST=$DEVNULL | |
bf6ae429 | 327 | create_lttng_session_ok $session_name $OUTPUT_DIR |
827caf52 | 328 | enable_ust_lttng_channel_ok $session_name $channel_name |
01513c3e JRJ |
329 | |
330 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
331 | #Test the enable event for ust domain | |
c4926bb5 | 332 | enable_ust_lttng_event_ok $session_name ${event[0]} $channel_name |
01513c3e JRJ |
333 | $XML_VALIDATE $OUTPUT_DEST |
334 | ok $? "Mi test: Enable_event for ust domain xsd validation" | |
335 | is_command_success $OUTPUT_DEST false | |
336 | ||
337 | #Try to reenable an enabled event. Should fail | |
c4926bb5 | 338 | enable_ust_lttng_event_fail $session_name ${event[0]} $channel_name |
01513c3e JRJ |
339 | $XML_VALIDATE $OUTPUT_DEST |
340 | ok $? "Mi test: Fail enable_event for ust domain xsd validation" | |
341 | is_command_success $OUTPUT_DEST true | |
342 | ||
343 | #Enable multiple event including the last one command will fail | |
344 | #But 2 events should success | |
345 | ||
346 | #Nice little hack, create a string ev,ev,ev | |
347 | #IFS stand for Internal field separator | |
348 | #Event[*] print all the element inside the array with the IFS in between | |
349 | concat_event=$( IFS=$','; echo "${event[*]}" ) | |
350 | ||
c4926bb5 | 351 | enable_ust_lttng_event_fail $session_name $concat_event $channel_name |
01513c3e JRJ |
352 | $XML_VALIDATE $OUTPUT_DEST |
353 | ok $? "Mi test: Multiple enable ust event with inside fail xsd validation" | |
354 | ||
4e1b4b38 | 355 | #Check for 2 success = true and 1 success = false |
01513c3e JRJ |
356 | extract_xml $OUTPUT_DEST $XPATH_ENABLE_EVENT_SUCCESS result |
357 | num_ocur=$(grep -o "true" <<< "$result" | wc -l) | |
358 | test "$num_ocur" -eq "2" | |
359 | ok $? "Mi test: Enabled event on failing enable command $num_ocur_true/2" | |
360 | ||
361 | extract_xml $OUTPUT_DEST $XPATH_ENABLE_EVENT_SUCCESS result | |
362 | num_ocur=$(grep -o "false" <<< "$result" | wc -l) | |
363 | test "$num_ocur" -eq "1" | |
364 | ok $? "Mi test: Enabled event on failing enable command $num_ocur_true/2" | |
365 | ||
366 | #Disable the event | |
367 | disable_ust_lttng_event $session_name ${event[0]} $channel_name | |
368 | $XML_VALIDATE $OUTPUT_DEST | |
369 | ok $? "Mi test: Disable ust event xsd validation" | |
370 | is_command_success $OUTPUT_DEST false | |
371 | ||
372 | #Disable the 3 event combined. Should pass | |
373 | disable_ust_lttng_event $session_name $concat_event $channel_name | |
374 | $XML_VALIDATE $OUTPUT_DEST | |
375 | ok $? "Mi test: Disable multiple ust event xsd validation" | |
376 | is_command_success $OUTPUT_DEST false | |
377 | ||
378 | #Make sure we have 3 inner success | |
379 | extract_xml $OUTPUT_DEST $XPATH_DISABLE_EVENT_SUCCESS result | |
380 | num_ocur=$(grep -o "true" <<< "$result" | wc -l) | |
381 | test "$num_ocur" -eq "3" | |
382 | ok $? "Mi test: Disable multiple ust event success $num_ocur/3" | |
383 | ||
384 | #Teardown | |
385 | OUTPUT_DEST=$DEVNULL | |
386 | destroy_lttng_sessions | |
387 | } | |
388 | ||
389 | function test_list_channel () | |
390 | { | |
391 | local session_name="testSession" | |
392 | local channel_name="testChannel" | |
393 | local event=("ev1" "ev2" "ev3") | |
394 | ||
395 | OUTPUT_FILE="list_channel.xml" | |
396 | ||
397 | #Test buid up | |
398 | OUTPUT_DEST=$DEVNULL | |
bf6ae429 | 399 | create_lttng_session_ok $session_name $OUTPUT_DIR |
827caf52 | 400 | enable_ust_lttng_channel_ok $session_name $channel_name |
01513c3e JRJ |
401 | |
402 | #Enable ust and jul events | |
403 | concat_event=$( IFS=$','; echo "${event[*]}" ) | |
c4926bb5 | 404 | enable_ust_lttng_event_ok $session_name $concat_event $channel_name |
01513c3e JRJ |
405 | |
406 | #Begin testing | |
407 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
408 | list_lttng_with_opts "$session_name -c $channel_name" | |
409 | $XML_VALIDATE $OUTPUT_DEST | |
410 | ok $? "Mi test: list channel xsd validation" | |
411 | ||
412 | #Expect 1 domain: UST | |
41af1adf | 413 | extract_xml $OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result |
01513c3e JRJ |
414 | num=$(echo "$result" | wc -l) |
415 | test "$num" -eq "1" | |
416 | ok $? "Mi test: $num / 1 domains discovered" | |
417 | ||
418 | #Expect 1 channel: test | |
41af1adf | 419 | extract_xml $OUTPUT_DEST $XPATH_LIST_CHANNEL"/lttng:name/text()" result |
01513c3e JRJ |
420 | num=$(echo "$result" | wc -l) |
421 | test "$num" -eq "1" | |
422 | ok $? "Mi test: $num / 1 channel discovered" | |
423 | ||
424 | test "$result" = "$channel_name" | |
425 | ok $? "Mi test: expected channel: $channel_name found: $result" | |
426 | ||
427 | #Add a channel and make sure we have 2 channel now | |
428 | OUTPUT_DEST=$DEVNULL | |
827caf52 | 429 | enable_ust_lttng_channel_ok $session_name $channel_name"a" |
01513c3e JRJ |
430 | |
431 | #Teardown | |
432 | OUTPUT_DEST=$DEVNULL | |
433 | destroy_lttng_sessions | |
434 | } | |
435 | ||
436 | function test_list_domain () | |
437 | { | |
438 | local session_name="testSession" | |
439 | local channel_name="testChannel" | |
440 | local event=("ev1" "ev2" "ev3") | |
441 | ||
442 | OUTPUT_FILE="list_domain.xml" | |
443 | ||
444 | #Test buid up | |
445 | OUTPUT_DEST=$DEVNULL | |
bf6ae429 | 446 | create_lttng_session_ok $session_name $OUTPUT_DIR |
827caf52 | 447 | enable_ust_lttng_channel_ok $session_name $channel_name |
01513c3e JRJ |
448 | |
449 | #Enable ust and jul events | |
450 | concat_event=$( IFS=$','; echo "${event[*]}" ) | |
c4926bb5 | 451 | enable_ust_lttng_event_ok $session_name $concat_event $channel_name |
01513c3e JRJ |
452 | enable_jul_lttng_event $session_name $concat_event $channel_name |
453 | ||
454 | #Begin testing | |
455 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
456 | list_lttng_with_opts "$session_name -d" | |
457 | $XML_VALIDATE $OUTPUT_DEST | |
458 | ok $? "Mi test: list domain xsd validation" | |
459 | ||
460 | #Expect 2 domain: Jul and UST | |
41af1adf | 461 | extract_xml $OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result |
01513c3e JRJ |
462 | num=$(echo "$result" | wc -l) |
463 | test "$num" -eq "2" | |
464 | ok $? "Mi test: $num / 2 domains discovered" | |
465 | ||
466 | #Test for valid value | |
467 | if [[ "$result" = *"JUL"* ]]; then | |
468 | pass "Mi test: domains Jul is present" | |
469 | else | |
470 | fail "Mi test: domains Jul is absent" | |
471 | fi | |
472 | ||
473 | if [[ "$result" = *"UST"* ]]; then | |
474 | pass "Mi test: domains UST is present" | |
475 | else | |
476 | fail "Mi test: domains UST is absent" | |
477 | fi | |
478 | ||
479 | #Teardown | |
480 | OUTPUT_DEST=$DEVNULL | |
481 | destroy_lttng_sessions | |
482 | } | |
483 | ||
484 | function test_list_session () | |
485 | { | |
486 | local session_name="testSession" | |
487 | local channel_name="testChannel" | |
488 | local event=("ev1" "ev2" "ev3") | |
489 | ||
490 | OUTPUT_FILE="list_session.xml" | |
491 | ||
492 | #Test buid up | |
493 | OUTPUT_DEST=$DEVNULL | |
bf6ae429 | 494 | create_lttng_session_ok $session_name $OUTPUT_DIR |
827caf52 | 495 | enable_ust_lttng_channel_ok $session_name $channel_name |
01513c3e JRJ |
496 | |
497 | #Enable ust and jul events | |
498 | concat_event=$( IFS=$','; echo "${event[*]}" ) | |
c4926bb5 | 499 | enable_ust_lttng_event_ok $session_name $concat_event $channel_name |
01513c3e JRJ |
500 | enable_jul_lttng_event $session_name $concat_event $channel_name |
501 | ||
502 | #Begin testing | |
503 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
504 | list_lttng_with_opts $session_name | |
505 | $XML_VALIDATE $OUTPUT_DEST | |
506 | ok $? "Mi test: list session xsd validation" | |
507 | ||
508 | #Expect 2 domain: Jul and UST | |
41af1adf | 509 | extract_xml $OUTPUT_DEST $XPATH_LIST_DOMAIN"/lttng:type/text()" result |
01513c3e JRJ |
510 | num=$(echo "$result" | wc -l) |
511 | test "$num" -eq "2" | |
512 | ok $? "Mi test: $num / 2 domains discovered" | |
513 | ||
514 | #Expect 2 channel: test and lttng_jul_event | |
41af1adf | 515 | extract_xml $OUTPUT_DEST $XPATH_LIST_CHANNEL"/lttng:name/text()" result |
01513c3e JRJ |
516 | num=$(echo "$result" | wc -l) |
517 | test "$num" -eq "2" | |
518 | ok $? "Mi test: $num / 2 channel discovered" | |
519 | ||
520 | #Teardown | |
521 | OUTPUT_DEST=$DEVNULL | |
522 | destroy_lttng_sessions | |
523 | } | |
524 | ||
525 | function test_list_ust_event () | |
526 | { | |
1c240f7e MD |
527 | local file_sync_after_first=$(mktemp -u) |
528 | local file_sync_before_last=$(mktemp -u) | |
529 | ||
01513c3e JRJ |
530 | OUTPUT_FILE="list_ust_event.xml" |
531 | ||
532 | #Test buid up | |
533 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
534 | ||
535 | #Begin testing | |
6c4a91d6 MD |
536 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \ |
537 | --sync-after-first-event ${file_sync_after_first} \ | |
538 | --sync-before-last-event ${file_sync_before_last} & 2>/dev/null | |
1c240f7e MD |
539 | |
540 | while [ ! -f "${file_sync_after_first}" ]; do | |
541 | sleep 0.5 | |
542 | done | |
543 | ||
01513c3e | 544 | list_lttng_with_opts "-u -f" |
1c240f7e MD |
545 | |
546 | touch ${file_sync_before_last} | |
547 | ||
01513c3e JRJ |
548 | $XML_VALIDATE $OUTPUT_DEST |
549 | ok $? "Mi test: list ust event xsd validation" | |
550 | ||
4e1b4b38 | 551 | #Extract events |
41af1adf | 552 | extract_xml $OUTPUT_DEST "$XPATH_LIST_UST_EVENT""/lttng:name/text()" result |
01513c3e | 553 | num=$(echo "$result" | wc -l) |
4e1b4b38 JR |
554 | |
555 | #Since the number of events is prone to change we only look for >= from a | |
556 | #base number. An alternative would be to look for each events but this | |
557 | #is complicated for nothing. | |
558 | test "$num" -ge "5" | |
50a74617 | 559 | ok $? "Mi test: $num / 5 ust events discovered" |
01513c3e | 560 | |
4e1b4b38 JR |
561 | #Extract field from tp:tptest event. Expect >= to 12 because number of |
562 | #field is prone to change. | |
41af1adf | 563 | extract_xml $OUTPUT_DEST "$XPATH_LIST_UST_EVENT""[./lttng:name = 'tp:tptest']/lttng:event_fields/lttng:event_field/lttng:name/text()" result |
01513c3e | 564 | num=$(echo "$result" | wc -l) |
4e1b4b38 | 565 | test "$num" -ge "12" |
01513c3e JRJ |
566 | ok $? "Mi test: $num / 12 ust event fields discovered" |
567 | ||
5402fe87 MD |
568 | #Wait for all background processes |
569 | wait | |
1c240f7e MD |
570 | |
571 | rm -f ${file_sync_after_first} | |
572 | rm -f ${file_sync_before_last} | |
01513c3e JRJ |
573 | } |
574 | ||
575 | function test_start_stop () { | |
576 | local session_name="testStartStopSession" | |
577 | local channel_name="startStopChannel" | |
578 | ||
579 | OUTPUT_FILE="list_start_stop.xml" | |
580 | ||
581 | #Test buid up | |
582 | OUTPUT_DEST=$DEVNULL | |
bf6ae429 | 583 | create_lttng_session_ok $session_name $OUTPUT_DIR |
01513c3e JRJ |
584 | |
585 | #Test fail command | |
586 | #No channel enable start command should return element success false | |
587 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
e563bbdb | 588 | start_lttng_tracing_fail $session_name |
01513c3e JRJ |
589 | $XML_VALIDATE $OUTPUT_DEST |
590 | ok $? "Mi test: failed start xsd validation" | |
591 | ||
592 | #Expect a false element | |
593 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
594 | test "$result" = "false" | |
595 | ok $? "Mi test: mi report failure on start command as expected" | |
596 | ||
597 | #Enable a channel to test success | |
598 | OUTPUT_DEST=$DEVNULL | |
827caf52 | 599 | enable_ust_lttng_channel_ok $session_name $channel_name |
01513c3e JRJ |
600 | |
601 | #Start tracing | |
602 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
e563bbdb | 603 | start_lttng_tracing_ok $session_name |
01513c3e JRJ |
604 | $XML_VALIDATE $OUTPUT_DEST |
605 | ok $? "Mi test: start xsd validation" | |
606 | ||
607 | #Expect a true element | |
608 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
609 | test "$result" = "true" | |
610 | ok $? "Mi test: mi report success on start command as expected" | |
611 | ||
612 | #Extract session name from xml | |
41af1adf | 613 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result |
01513c3e JRJ |
614 | test "$result" = "$session_name" |
615 | ok $? "Mi test: started $session_name" | |
616 | ||
617 | #Extract enabled expect true | |
41af1adf | 618 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:enabled/text()" result |
01513c3e JRJ |
619 | test "$result" = "true" |
620 | ok $? "Mi test: enabled element : $result expected: true" | |
621 | ||
54897b57 | 622 | #Test metadata regenerate command |
eded6438 | 623 | regenerate_metadata_ok $session_name |
54897b57 | 624 | $XML_VALIDATE $OUTPUT_DEST |
eded6438 | 625 | ok $? "Mi test: regenerate metadata" |
54897b57 | 626 | |
01513c3e | 627 | #Test stop command |
96340a01 | 628 | stop_lttng_tracing_ok $session_name |
01513c3e JRJ |
629 | $XML_VALIDATE $OUTPUT_DEST |
630 | ok $? "Mi test: stop xsd validation" | |
631 | ||
632 | #Extract session name from xml | |
41af1adf | 633 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result |
01513c3e | 634 | test "$result" = "$session_name" |
5de63f6d | 635 | ok $? "Mi test: stopped $session_name" |
01513c3e JRJ |
636 | |
637 | #Extract enabled expect false | |
41af1adf | 638 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:enabled/text()" result |
01513c3e JRJ |
639 | test "$result" = "false" |
640 | ok $? "Mi test: enabled element : $result expected: false" | |
641 | ||
642 | #Test failing stop command | |
96340a01 | 643 | stop_lttng_tracing_fail $session_name |
01513c3e JRJ |
644 | $XML_VALIDATE $OUTPUT_DEST |
645 | ok $? "Mi test: failed stop xsd validation" | |
646 | ||
647 | #Expect a false element | |
648 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
649 | test "$result" = "false" | |
650 | ok $? "Mi test: mi report failure on start command as expected" | |
651 | ||
652 | #Teardown | |
653 | OUTPUT_DEST=$DEVNULL | |
654 | destroy_lttng_sessions | |
01513c3e JRJ |
655 | } |
656 | ||
657 | function test_snapshot () { | |
658 | local session_name="testSnapshotAdd" | |
659 | local snapshot_path="$OUTPUT_DIR/snapshotoutput" | |
660 | OUTPUT_FILE="snapshot.xml" | |
661 | ||
662 | ||
663 | #Test buid up | |
664 | OUTPUT_DEST=$DEVNULL | |
665 | create_lttng_session_no_output $session_name | |
666 | ||
667 | #Test fail command | |
668 | #No channel enable start command should return element success false | |
669 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
9f0e230a | 670 | lttng_snapshot_add_output_ok $session_name file://$snapshot_path |
01513c3e JRJ |
671 | $XML_VALIDATE $OUTPUT_DEST |
672 | ok $? "Mi test: snapshot xsd validation" | |
673 | ||
674 | #Expect a true element | |
675 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
676 | test "$result" = "true" | |
677 | ok $? "Mi test: add snapshot is a success" | |
678 | ||
679 | #Get data | |
41af1adf | 680 | extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:session_name/text()" result |
01513c3e JRJ |
681 | test "$result" = "$session_name" |
682 | ok $? "Mi test: added snapshot for: $result expected $session_name" | |
683 | ||
684 | #Get name of generated output and id | |
41af1adf JG |
685 | extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:name/text()" snapshot_name |
686 | extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_ADD_SNAPSHOT""/lttng:snapshot/lttng:id/text()" snapshot_id | |
01513c3e JRJ |
687 | |
688 | #Test list output | |
689 | lttng_snapshot_list $session_name | |
690 | $XML_VALIDATE $OUTPUT_DEST | |
691 | ok $? "Mi test: snapshot list xsd validation" | |
692 | ||
693 | #Expect a true element | |
694 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
695 | test "$result" = "true" | |
696 | ok $? "Mi test: add snapshot is a success" | |
697 | ||
41af1adf | 698 | extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_LIST""/lttng:session[./lttng:name ='$session_name']/lttng:snapshots/lttng:snapshot/lttng:name/text()" result |
01513c3e JRJ |
699 | test "$result" = "$snapshot_name" |
700 | ok $? "Mi test: snapshot list extracted snapshot: $result expected: $snapshot_name" | |
701 | ||
702 | #Test del output | |
31580dc7 | 703 | lttng_snapshot_del_output_ok $session_name $snapshot_id |
01513c3e JRJ |
704 | $XML_VALIDATE $OUTPUT_DEST |
705 | ok $? "Mi test: snapshot delete xsd validation" | |
706 | ||
707 | #Success ? | |
708 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
709 | test "$result" = "true" | |
710 | ok $? "Mi test: del snapshot is a success" | |
711 | ||
712 | #Test data | |
41af1adf | 713 | extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/lttng:snapshot/lttng:id/text()" result |
01513c3e JRJ |
714 | test "$result" = "$snapshot_id" |
715 | ok $? "Mi test: snapshot del extracted snapshot id: $result expected: $snapshot_id" | |
716 | ||
41af1adf | 717 | extract_xml $OUTPUT_DEST "$XPATH_SNAPSHOT_DEL""/lttng:snapshot/lttng:session_name/text()" result |
01513c3e JRJ |
718 | test "$result" = "$session_name" |
719 | ok $? "Mi test: snapshot del extracted snapshot id: $result expected: $session_name" | |
720 | ||
721 | #Test fail on delete command | |
31580dc7 | 722 | lttng_snapshot_del_output_fail $session_name $snapshot_id |
01513c3e JRJ |
723 | $XML_VALIDATE $OUTPUT_DEST |
724 | ok $? "Mi test: snapshot delete xsd validation" | |
725 | ||
726 | #Success ? | |
727 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
728 | test "$result" = "false" | |
729 | ok $? "Mi test: del snapshot is a success" | |
730 | ||
731 | OUTPUT_DEST=$DEVNULL | |
732 | destroy_lttng_sessions | |
733 | } | |
734 | ||
e83a8bdb JR |
735 | function test_track_untrack () |
736 | { | |
737 | diag "Test track/untrack pid" | |
738 | ||
739 | local session_name="testTrack" | |
e83a8bdb JR |
740 | local pid="1,2,3" |
741 | OUTPUT_FILE="track.xml" | |
742 | ||
743 | #Test buid up | |
744 | OUTPUT_DEST=$DEVNULL | |
745 | create_lttng_session_no_output $session_name | |
746 | ||
747 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
748 | lttng_track_ok "-p $pid -u" | |
749 | $XML_VALIDATE $OUTPUT_DEST | |
750 | ok $? "Mi test: track pid xsd validation" | |
751 | ||
752 | #Expect a true element | |
753 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
754 | test "$result" = "true" | |
755 | ok $? "Mi test: track pid is a success" | |
756 | ||
757 | #Verify that there is 3 process | |
83d6d6c4 | 758 | extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_VPID"/lttng:id" result |
e83a8bdb JR |
759 | num=$(echo "$result" | wc -l) |
760 | test "$num" -eq "3" | |
761 | ok $? "Mi test: track pid expecting 3 processes got $num" | |
762 | ||
e83a8bdb JR |
763 | #Test the pid_tracker listing |
764 | list_lttng_with_opts $session_name | |
765 | $XML_VALIDATE $OUTPUT_DEST | |
766 | ok $? "Mi test: session list with pid_tracker validate" | |
767 | ||
768 | #Check the good count | |
159b042f | 769 | extract_xml $OUTPUT_DEST $XPATH_VPID_TRACKER"/lttng:process_attr_values/lttng:vpid/lttng:type/lttng:id" result |
e83a8bdb JR |
770 | num=$(echo "$result" | wc -l) |
771 | test "$num" -eq "3" | |
772 | ok $? "Mi test: tracker pid listing expecting 3 target got $num" | |
773 | ||
774 | #Untrack pid 2,3 | |
775 | lttng_untrack_ok "-p 2,3 -u" | |
776 | $XML_VALIDATE $OUTPUT_DEST | |
777 | ok $? "Mi test: untrack pid xsd validation" | |
778 | ||
779 | #Expect a true element | |
780 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
781 | test "$result" = "true" | |
782 | ok $? "Mi test: untrack pid is a success" | |
783 | ||
784 | #Verify that there is 2 untracked pids | |
83d6d6c4 | 785 | extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_VPID"/lttng:id" result |
e83a8bdb JR |
786 | num=$(echo "$result" | wc -l) |
787 | test "$num" -eq "2" | |
788 | ok $? "Mi test: untrack pid expecting 2 process got $num" | |
789 | ||
e83a8bdb JR |
790 | #Check pid_tracker listing |
791 | list_lttng_with_opts $session_name | |
792 | $XML_VALIDATE $OUTPUT_DEST | |
793 | ok $? "Mi test: session list with pid_tracker validate" | |
794 | ||
795 | #Check the good count | |
83d6d6c4 | 796 | extract_xml $OUTPUT_DEST $XPATH_VPID_TRACKER"/lttng:targets/lttng:vpid_target/lttng:type/lttng:pid" result |
e83a8bdb JR |
797 | num=$(echo "$result" | wc -l) |
798 | test "$num" -eq "1" | |
799 | ok $? "Mi test: tracker pid listing expecting 1 process got $num" | |
800 | ||
801 | #Untrack all | |
802 | lttng_untrack_ok "-p -u -a" | |
803 | $XML_VALIDATE $OUTPUT_DEST | |
804 | ok $? "Mi test: untrack pid xsd validation" | |
805 | ||
806 | #Expect a true element | |
807 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
808 | test "$result" = "true" | |
809 | ok $? "Mi test: untrack all pid is a success" | |
810 | ||
811 | #Verify that there is 1 untracked pid | |
83d6d6c4 | 812 | extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_VPID"/lttng:all" result |
e83a8bdb JR |
813 | num=$(echo "$result" | wc -l) |
814 | test "$num" -eq "1" | |
815 | ok $? "Mi test: untrack pid expecting 1 process got $num" | |
816 | ||
83d6d6c4 JR |
817 | #Test if type "all" is "true" which represent the all argument |
818 | test "$result" = "true" | |
819 | ok $? "Mi test: pid expected is true got $result" | |
e83a8bdb JR |
820 | |
821 | #Test if pid_tracker is enabled as definied by pid_tracker | |
822 | #behavior. If all pid are untrack than the pid_tracker is still | |
823 | #enabled (pid_tracker node is present). | |
824 | list_lttng_with_opts $session_name | |
825 | $XML_VALIDATE $OUTPUT_DEST | |
826 | ok $? "Mi test: session list with pid_tracker validate" | |
827 | ||
828 | #Check the good count | |
83d6d6c4 | 829 | extract_xml $OUTPUT_DEST $XPATH_VPID_TRACKER"/lttng:targets/lttng:vpid_target/lttng:type/lttng:pid" result |
e83a8bdb JR |
830 | num=$(echo -n "$result" | wc -l) |
831 | test "$num" -eq "0" | |
832 | ok $? "Mi test: tracker pid listing expecting 0 process got $num" | |
833 | ||
834 | #Test track all | |
835 | lttng_track_ok "-p -u -a" | |
836 | $XML_VALIDATE $OUTPUT_DEST | |
837 | ok $? "Mi test: track pid xsd validation" | |
838 | ||
839 | #Expect a true element | |
840 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
841 | test "$result" = "true" | |
842 | ok $? "Mi test: track all pid is a success" | |
843 | ||
844 | #Verify that there is 1 tracked process | |
83d6d6c4 | 845 | extract_xml $OUTPUT_DEST $XPATH_TRACK_UNTRACK_VPID"/lttng:all" result |
e83a8bdb JR |
846 | num=$(echo "$result" | wc -l) |
847 | test "$num" -eq "1" | |
848 | ok $? "Mi test: track pid expecting 1 process got $num" | |
849 | ||
83d6d6c4 JR |
850 | #Test if the id is true wich represent the all argument |
851 | test "$result" = "true" | |
852 | ok $? "Mi test: pid expected is true got $result" | |
e83a8bdb JR |
853 | |
854 | #Test if pid_tracker is enabled as definied by pid_tracker | |
855 | #behavior. If all pid are untrack thant the pid_tracker is | |
856 | #disabled (node pid_tracker do not exist) | |
857 | list_lttng_with_opts $session_name | |
858 | $XML_VALIDATE $OUTPUT_DEST | |
859 | ok $? "Mi test: session list with pid_tracker validate" | |
860 | ||
83d6d6c4 | 861 | node_check_xml $OUTPUT_DEST $XPATH_VPID_TRACKER result |
e83a8bdb | 862 | test "$result" = "" |
83d6d6c4 | 863 | ok $? "Mi test: VPID_tracker node is absent as defined" |
e83a8bdb JR |
864 | |
865 | OUTPUT_DEST=$DEVNULL | |
866 | destroy_lttng_sessions | |
867 | } | |
868 | ||
59deec0c JR |
869 | function test_add_context_list() |
870 | { | |
871 | diag "Test context listing" | |
872 | ||
873 | OUTPUT_FILE="list-context.xml" | |
874 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
875 | lttng_add_context_list | |
876 | ||
877 | $XML_VALIDATE $OUTPUT_DEST | |
878 | ok $? "Mi test: context listing validation" | |
879 | } | |
880 | ||
5ee26199 JR |
881 | function test_clear_session () |
882 | { | |
883 | # Since the session are not started there is no real clear done. | |
884 | # We are testing the MI output only here. | |
885 | local session_name=( | |
886 | "testSession1" | |
887 | "testSession2" | |
888 | "testSession3") | |
889 | ||
890 | OUTPUT_FILE="clear_session.xml" | |
891 | ||
892 | #Test build up | |
893 | OUTPUT_DEST=$DEVNULL | |
894 | for (( i = 0; i < 3; i++ )); do | |
895 | create_lttng_session_ok ${session_name[$i]} $OUTPUT_DIR | |
896 | done | |
897 | ||
898 | OUTPUT_DEST=$OUTPUT_DIR/$OUTPUT_FILE | |
899 | lttng_clear_session_ok ${session_name[0]} | |
900 | $XML_VALIDATE $OUTPUT_DEST | |
901 | ok $? "MI test: clear session ${session_name[0]} xsd validation" | |
902 | ||
903 | #Verify that we cleared the good session | |
904 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result | |
905 | test "$result" = "${session_name[0]}" | |
906 | ok $? "Mi test: cleared session: $result expected: ${session_name[0]}" | |
907 | ||
908 | #Destroy all and count:should be 3 | |
909 | lttng_clear_all | |
910 | $XML_VALIDATE $OUTPUT_DEST | |
911 | ok $? "MI test: clear all session xsd validation" | |
912 | ||
913 | #Verify that we cleared 3 sessions | |
914 | extract_xml $OUTPUT_DEST $XPATH_SESSION"/lttng:name/text()" result | |
915 | num=$(echo "$result" | wc -l) | |
916 | test "$num" -eq "3" | |
917 | ok $? "Mi test: $num / 3 sessions discovered" | |
918 | ||
919 | destroy_lttng_sessions | |
920 | ||
921 | #Verify that if no session is present command fail and mi report it. | |
922 | lttng_clear_session_fail ${session_name[0]} | |
923 | $XML_VALIDATE $OUTPUT_DEST | |
924 | ok $? "MI test: failing clear session ${session_name[0]} xsd validation" | |
925 | extract_xml $OUTPUT_DEST $XPATH_COMMAND_SUCCESS result | |
926 | test "$result" = "false" | |
927 | ok $? "Mi test: clear command on ${session_name[0]} failed as expected" | |
928 | ||
929 | } | |
930 | ||
151c0584 | 931 | start_lttng_sessiond $SESSIOND_LOAD_DIR |
312dabc3 JRJ |
932 | TESTS=( |
933 | test_version | |
934 | test_create_session | |
935 | test_destroy_session | |
936 | test_list_sessions | |
937 | test_ust_channel | |
01513c3e JRJ |
938 | test_ust_lttng_event |
939 | test_list_channel | |
940 | test_list_domain | |
941 | test_list_session | |
942 | test_list_ust_event | |
943 | test_start_stop | |
944 | test_snapshot | |
e83a8bdb | 945 | test_track_untrack |
c764163f | 946 | test_list_session_long_path |
59deec0c | 947 | test_add_context_list |
5ee26199 | 948 | test_clear_session |
312dabc3 JRJ |
949 | ) |
950 | ||
01513c3e | 951 | |
312dabc3 JRJ |
952 | echo $OUTPUT_DIR |
953 | for fct_test in ${TESTS[@]}; | |
954 | do | |
312dabc3 JRJ |
955 | ${fct_test} |
956 | if [ $? -ne 0 ]; then | |
957 | break; | |
958 | fi | |
312dabc3 | 959 | done |
01513c3e | 960 | rm -rf $OUTPUT_DIR |
6bf9addc | 961 | rm -rf $FOO_LOAD_DIR |
312dabc3 JRJ |
962 | |
963 | OUTPUT_DEST=/dev/null 2>&1 | |
964 | stop_lttng_sessiond |