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