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