Commit | Line | Data |
---|---|---|
a9115ebf JR |
1 | #!/bin/bash |
2 | # | |
9d16b343 | 3 | # Copyright (C) 2018 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> |
a9115ebf | 4 | # |
9d16b343 | 5 | # SPDX-License-Identifier: LGPL-2.1-only |
a9115ebf JR |
6 | |
7 | TEST_DESC="LTTng relayd filesystem grouping - Userspace tracing" | |
8 | ||
9 | CURDIR=$(dirname "$0")/ | |
10 | TESTDIR=$CURDIR/../../.. | |
11 | NR_ITER=10 | |
12 | NR_USEC_WAIT=100 | |
13 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
14 | TESTAPP_NAME="gen-ust-events" | |
15 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
16 | EVENT_NAME="tp:tptest" | |
17 | CHANNEL_NAME="my_channel" | |
18 | ||
a9115ebf JR |
19 | XPATH_CMD_OUTPUT="//lttng:command/lttng:output" |
20 | XPATH_SESSION="$XPATH_CMD_OUTPUT/lttng:sessions/lttng:session" | |
21 | ||
a9115ebf JR |
22 | NUM_TESTS=688 |
23 | ||
24 | source "$TESTDIR/utils/utils.sh" | |
25 | ||
26 | if [ ! -x "$TESTAPP_BIN" ]; then | |
27 | BAIL_OUT "No UST events binary detected." | |
28 | fi | |
29 | ||
30 | function get_auto_session_name () | |
31 | { | |
32 | local __result=$1 | |
33 | ||
34 | local lttng_bin=$LTTNG_BIN | |
35 | ||
36 | LTTNG_BIN="${lttng_bin} --mi xml" | |
7539dcec | 37 | OUTPUT_DEST=$(mktemp --tmpdir "tmp.${FUNCNAME[0]}_output.XXXXXX") |
a9115ebf JR |
38 | |
39 | list_lttng_with_opts | |
045ce78b | 40 | $MI_VALIDATE "$OUTPUT_DEST" |
a9115ebf JR |
41 | ok $? "Valid lttng list XML" |
42 | ||
43 | value=$($XML_EXTRACT "$OUTPUT_DEST" ${XPATH_SESSION}/lttng:name/text\(\)) | |
44 | ok $? "Extraction of session name" | |
8c635ee9 | 45 | rm -f $OUTPUT_DEST |
a9115ebf JR |
46 | OUTPUT_DEST=/dev/null |
47 | LTTNG_BIN=$lttng_bin | |
48 | ||
49 | # Transfer value to passed arguments | |
50 | eval "$__result='$value'" | |
51 | } | |
52 | ||
53 | function test_ust_uid_live () | |
54 | { | |
55 | local session_name="$1" | |
56 | local grouping="$2" | |
57 | local is_automatic_session=false | |
58 | ||
59 | if [ -z "$session_name" ]; then | |
60 | is_automatic_session=true | |
61 | fi | |
62 | ||
63 | diag "Test UST uid buffer live [$grouping][${session_name:-automatic session name}]" | |
64 | ||
65 | create_lttng_session_uri "$session_name" net://localhost --live | |
66 | if [ "$is_automatic_session" = true ]; then | |
67 | get_auto_session_name session_name | |
68 | fi | |
69 | ||
70 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid" | |
71 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
72 | start_lttng_tracing_ok "$session_name" | |
73 | ||
6c4a91d6 | 74 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
75 | |
76 | stop_lttng_tracing_ok "$session_name" | |
77 | destroy_lttng_session_ok "$session_name" | |
78 | ||
79 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
80 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*" | |
81 | else | |
82 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*" | |
83 | fi | |
84 | ||
85 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
86 | rm -rf "${TRACE_PATH:?}/$session_name" | |
87 | else | |
88 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
89 | fi | |
90 | } | |
91 | ||
92 | function test_ust_pid_live () | |
93 | { | |
94 | local session_name="$1" | |
95 | local grouping="$2" | |
96 | local is_automatic_session=false | |
97 | ||
98 | if [ -z "$session_name" ]; then | |
99 | is_automatic_session=true | |
100 | fi | |
101 | ||
102 | diag "Test UST pid buffer live [$grouping][${session_name:-automatic session name}]" | |
103 | ||
104 | create_lttng_session_uri "$session_name" net://localhost --live | |
105 | if [ "$is_automatic_session" = true ]; then | |
106 | get_auto_session_name session_name | |
107 | fi | |
108 | ||
109 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid" | |
110 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
111 | start_lttng_tracing_ok "$session_name" | |
112 | ||
6c4a91d6 | 113 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
114 | |
115 | stop_lttng_tracing_ok "$session_name" | |
116 | destroy_lttng_session_ok "$session_name" | |
117 | ||
118 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
119 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*" | |
120 | else | |
121 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*" | |
122 | fi | |
123 | ||
124 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
125 | rm -rf "${TRACE_PATH:?}/$session_name" | |
126 | else | |
127 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
128 | fi | |
129 | } | |
130 | ||
131 | function test_ust_uid_live_custom_output () | |
132 | { | |
133 | local session_name="$1" | |
134 | local grouping="$2" | |
135 | local custom_output="my_live_custom_output" | |
136 | local is_automatic_session=false | |
137 | ||
138 | if [ -z "$session_name" ]; then | |
139 | is_automatic_session=true | |
140 | fi | |
141 | ||
142 | diag "Test UST uid buffer live, custom output [$grouping][${session_name:-automatic session name}]" | |
143 | ||
144 | create_lttng_session_uri "$session_name" net://localhost/$custom_output --live | |
145 | if [ "$is_automatic_session" = true ]; then | |
146 | get_auto_session_name session_name | |
147 | fi | |
148 | ||
149 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid" | |
150 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
151 | start_lttng_tracing_ok "$session_name" | |
152 | ||
6c4a91d6 | 153 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
154 | |
155 | stop_lttng_tracing_ok "$session_name" | |
156 | destroy_lttng_session_ok "$session_name" | |
157 | ||
158 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
159 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output" | |
160 | else | |
161 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$custom_output" | |
162 | fi | |
163 | ||
164 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
165 | rm -rf "${TRACE_PATH:?}/$session_name" | |
166 | else | |
167 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
168 | fi | |
169 | } | |
170 | ||
171 | function test_ust_uid_streaming () | |
172 | { | |
173 | local session_name="$1" | |
174 | local grouping="$2" | |
175 | local is_automatic_session=false | |
176 | ||
177 | if [ -z "$session_name" ]; then | |
178 | is_automatic_session=true | |
179 | fi | |
180 | ||
181 | diag "Test UST uid buffer streaming [$grouping][${session_name:-automatic session name}]" | |
182 | ||
183 | create_lttng_session_uri "$session_name" net://localhost | |
184 | if [ "$is_automatic_session" = true ]; then | |
185 | get_auto_session_name session_name | |
186 | fi | |
187 | ||
188 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid" | |
189 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
190 | start_lttng_tracing_ok "$session_name" | |
191 | ||
6c4a91d6 | 192 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
193 | |
194 | stop_lttng_tracing_ok "$session_name" | |
195 | destroy_lttng_session_ok "$session_name" | |
196 | ||
197 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
198 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*" | |
199 | else | |
200 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*" | |
201 | fi | |
202 | ||
203 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
204 | rm -rf "${TRACE_PATH:?}/$session_name" | |
205 | else | |
206 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
207 | fi | |
208 | } | |
209 | ||
210 | function test_ust_pid_streaming () | |
211 | { | |
212 | local session_name="$1" | |
213 | local grouping="$2" | |
214 | local is_automatic_session=false | |
215 | ||
216 | if [ -z "$session_name" ]; then | |
217 | is_automatic_session=true | |
218 | fi | |
219 | ||
220 | diag "Test UST pid buffer streaming [$grouping][${session_name:-automatic session name}]" | |
221 | ||
222 | create_lttng_session_uri "$session_name" net://localhost | |
223 | if [ "$is_automatic_session" = true ]; then | |
224 | get_auto_session_name session_name | |
225 | fi | |
226 | ||
227 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid" | |
228 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
229 | start_lttng_tracing_ok "$session_name" | |
230 | ||
6c4a91d6 | 231 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
232 | |
233 | stop_lttng_tracing_ok "$session_name" | |
234 | destroy_lttng_session_ok "$session_name" | |
235 | ||
236 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
237 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*" | |
238 | else | |
239 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*" | |
240 | fi | |
241 | ||
242 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
243 | rm -rf "${TRACE_PATH:?}/$session_name" | |
244 | else | |
245 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
246 | fi | |
247 | } | |
248 | ||
249 | function test_ust_uid_streaming_custom_output () | |
250 | { | |
251 | local session_name="$1" | |
252 | local grouping="$2" | |
253 | local custom_output="custom_second_token" | |
254 | local is_automatic_session=false | |
255 | ||
256 | if [ -z "$session_name" ]; then | |
257 | is_automatic_session=true | |
258 | fi | |
259 | ||
260 | diag "Test UST uid buffer streaming, custom output [$grouping][${session_name:-automatic session name}]" | |
261 | ||
262 | create_lttng_session_uri "$session_name" net://localhost/$custom_output | |
263 | if [ "$is_automatic_session" = true ]; then | |
264 | get_auto_session_name session_name | |
265 | fi | |
266 | ||
267 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid" | |
268 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
269 | start_lttng_tracing_ok "$session_name" | |
270 | ||
6c4a91d6 | 271 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
272 | |
273 | stop_lttng_tracing_ok "$session_name" | |
274 | destroy_lttng_session_ok "$session_name" | |
275 | ||
276 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
277 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output" | |
278 | else | |
279 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$custom_output" | |
280 | fi | |
281 | ||
282 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
283 | rm -rf "${TRACE_PATH:?}/$session_name" | |
284 | else | |
285 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
286 | fi | |
287 | } | |
288 | ||
289 | function test_ust_uid_streaming_rotate () | |
290 | { | |
291 | local session_name="$1" | |
292 | local grouping="$2" | |
293 | local is_automatic_session=false | |
294 | ||
295 | if [ -z "$session_name" ]; then | |
296 | is_automatic_session=true | |
297 | fi | |
298 | ||
299 | diag "Test UST uid buffer rotate [$grouping][${session_name:-automatic session name}]" | |
300 | ||
301 | create_lttng_session_uri "$session_name" net://localhost | |
302 | if [ "$is_automatic_session" = true ]; then | |
303 | get_auto_session_name session_name | |
304 | fi | |
305 | ||
306 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid" | |
307 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
308 | start_lttng_tracing_ok "$session_name" | |
309 | ||
6c4a91d6 | 310 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
311 | rotate_session_ok "$session_name" |
312 | ||
313 | stop_lttng_tracing_ok "$session_name" | |
314 | destroy_lttng_session_ok "$session_name" | |
315 | ||
316 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
317 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*" | |
318 | else | |
319 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*" | |
320 | fi | |
321 | ||
322 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
323 | rm -rf "${TRACE_PATH:?}/$session_name" | |
324 | else | |
325 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
326 | fi | |
327 | } | |
328 | ||
329 | function test_ust_uid_streaming_rotate_custom_output () | |
330 | { | |
331 | local session_name="$1" | |
332 | local grouping="$2" | |
333 | local custom_output="rotate_custom_path" | |
334 | local is_automatic_session=false | |
335 | ||
336 | if [ -z "$session_name" ]; then | |
337 | is_automatic_session=true | |
338 | fi | |
339 | ||
340 | diag "Test UST uid buffer rotate, custom output [$grouping][${session_name:-automatic session name}]" | |
341 | ||
342 | create_lttng_session_uri "$session_name" net://localhost/$custom_output | |
343 | if [ "$is_automatic_session" = true ]; then | |
344 | get_auto_session_name session_name | |
345 | fi | |
346 | ||
347 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid" | |
348 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
349 | start_lttng_tracing_ok "$session_name" | |
350 | ||
6c4a91d6 | 351 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
352 | rotate_session_ok "$session_name" |
353 | ||
354 | ||
355 | stop_lttng_tracing_ok "$session_name" | |
356 | destroy_lttng_session_ok "$session_name" | |
357 | ||
358 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
359 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output" | |
360 | else | |
361 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$custom_output" | |
362 | fi | |
363 | ||
364 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
365 | rm -rf "${TRACE_PATH:?}/$session_name" | |
366 | else | |
367 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
368 | fi | |
369 | } | |
370 | ||
371 | function test_ust_pid_streaming_rotate () | |
372 | { | |
373 | local session_name="$1" | |
374 | local grouping="$2" | |
375 | local is_automatic_session=false | |
376 | ||
377 | if [ -z "$session_name" ]; then | |
378 | is_automatic_session=true | |
379 | fi | |
380 | ||
381 | diag "Test UST pid buffer rotate with session_name [$grouping][${session_name:-automatic session name}]" | |
382 | ||
383 | create_lttng_session_uri "$session_name" net://localhost | |
384 | if [ "$is_automatic_session" = true ]; then | |
385 | get_auto_session_name session_name | |
386 | fi | |
387 | ||
388 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid" | |
389 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
390 | start_lttng_tracing_ok "$session_name" | |
391 | ||
6c4a91d6 | 392 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
393 | rotate_session_ok "$session_name" |
394 | ||
395 | stop_lttng_tracing_ok "$session_name" | |
396 | destroy_lttng_session_ok "$session_name" | |
397 | ||
398 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
399 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*" | |
400 | else | |
401 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*" | |
402 | fi | |
403 | ||
404 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
405 | rm -rf "${TRACE_PATH:?}/$session_name" | |
406 | else | |
407 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
408 | fi | |
409 | } | |
410 | ||
411 | function test_ust_uid_streaming_snapshot () | |
412 | { | |
413 | local session_name="$1" | |
414 | local grouping="$2" | |
415 | local is_automatic_session=false | |
416 | ||
417 | if [ -z "$session_name" ]; then | |
418 | is_automatic_session=true | |
419 | fi | |
420 | ||
421 | diag "Test UST uid buffer snapshot streaming using 'create --snapshot' [$grouping][${session_name:-automatic session name}]" | |
422 | ||
423 | create_lttng_session_uri "$session_name" net://localhost --snapshot | |
424 | if [ "$is_automatic_session" = true ]; then | |
425 | get_auto_session_name session_name | |
426 | fi | |
427 | ||
428 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-uid" | |
429 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
430 | start_lttng_tracing_ok "$session_name" | |
431 | ||
6c4a91d6 | 432 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
433 | lttng_snapshot_record "$session_name" |
434 | ||
435 | stop_lttng_tracing_ok "$session_name" | |
436 | destroy_lttng_session_ok "$session_name" | |
437 | ||
438 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
439 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME*" | |
440 | else | |
441 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*" | |
442 | fi | |
443 | ||
444 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
445 | rm -rf "${TRACE_PATH:?}/$session_name" | |
446 | else | |
447 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
448 | fi | |
449 | } | |
450 | ||
451 | function test_ust_pid_streaming_snapshot () | |
452 | { | |
453 | local session_name="$1" | |
454 | local grouping="$2" | |
455 | local is_automatic_session=false | |
456 | ||
457 | local file_sync_after_first | |
458 | local file_sync_before_last | |
459 | ||
7539dcec FD |
460 | file_sync_after_first=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX") |
461 | file_sync_before_last=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX") | |
a9115ebf JR |
462 | |
463 | if [ -z "$session_name" ]; then | |
464 | is_automatic_session=true | |
465 | fi | |
466 | ||
467 | diag "Test UST pid buffer snapshot streaming using 'create --snapshot' [$grouping][${session_name:-automatic session name}]" | |
468 | ||
469 | create_lttng_session_uri "$session_name" net://localhost --snapshot | |
470 | if [ "$is_automatic_session" = true ]; then | |
471 | get_auto_session_name session_name | |
472 | fi | |
473 | ||
474 | enable_ust_lttng_channel_ok "$session_name" "$CHANNEL_NAME" "--buffers-pid" | |
475 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
476 | start_lttng_tracing_ok "$session_name" | |
477 | ||
6c4a91d6 MD |
478 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \ |
479 | --sync-after-first-event "$file_sync_after_first" \ | |
480 | --sync-before-last-event "$file_sync_before_last" 2>&1 & | |
a9115ebf JR |
481 | |
482 | while [ ! -f "${file_sync_after_first}" ]; do | |
483 | sleep 0.5 | |
484 | done | |
485 | ||
486 | lttng_snapshot_record "$session_name" | |
487 | ||
488 | touch "$file_sync_before_last" | |
489 | wait | |
490 | ||
491 | stop_lttng_tracing_ok "$session_name" | |
492 | destroy_lttng_session_ok "$session_name" | |
493 | ||
494 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
495 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/snapshot-1*" | |
496 | else | |
497 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*/snapshot-1*" | |
498 | fi | |
499 | ||
500 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
501 | rm -rf "${TRACE_PATH:?}/$session_name" | |
502 | else | |
503 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
504 | fi | |
505 | ||
506 | rm -f "$file_sync_after_first" | |
507 | rm -f "$file_sync_before_last" | |
508 | } | |
509 | ||
510 | function test_ust_uid_streaming_snapshot_add_output_default_name () | |
511 | { | |
512 | local session_name="$1" | |
513 | local grouping="$2" | |
514 | local is_automatic_session=false | |
515 | ||
516 | if [ -z "$session_name" ]; then | |
517 | is_automatic_session=true | |
518 | fi | |
519 | ||
520 | diag "Test UST uid buffer snapshot using 'add-output' with default snapshot name [$grouping][${session_name:-automatic session name}]" | |
521 | ||
522 | create_lttng_session_no_output "$session_name" | |
523 | if [ "$is_automatic_session" = true ]; then | |
524 | get_auto_session_name session_name | |
525 | fi | |
526 | ||
527 | enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME" | |
528 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
529 | start_lttng_tracing_ok "$session_name" | |
530 | ||
6c4a91d6 | 531 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
532 | |
533 | lttng_snapshot_add_output_ok "$session_name" "net://localhost" | |
534 | lttng_snapshot_record "$session_name" | |
535 | ||
536 | stop_lttng_tracing_ok "$session_name" | |
537 | destroy_lttng_session_ok "$session_name" | |
538 | ||
539 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
540 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/snapshot-1*" | |
541 | else | |
542 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*/snapshot-1*" | |
543 | fi | |
544 | ||
545 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
546 | rm -rf "${TRACE_PATH:?}/$session_name" | |
547 | else | |
548 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
549 | fi | |
550 | } | |
551 | ||
552 | function test_ust_uid_streaming_snapshot_add_output_custom_name () | |
553 | { | |
554 | local session_name="$1" | |
555 | local grouping="$2" | |
556 | local snapshot_name="this_is_my_snapshot" | |
557 | local is_automatic_session=false | |
558 | ||
559 | if [ -z "$session_name" ]; then | |
560 | is_automatic_session=true | |
561 | fi | |
562 | ||
563 | diag "Test UST uid buffer snapshot using 'add-output' with custom snapshot name [$grouping][${session_name:-automatic session name}]" | |
564 | ||
565 | create_lttng_session_no_output "$session_name" | |
566 | if [ "$is_automatic_session" = true ]; then | |
567 | get_auto_session_name session_name | |
568 | fi | |
569 | ||
570 | enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME" | |
571 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
572 | start_lttng_tracing_ok "$session_name" | |
573 | ||
6c4a91d6 | 574 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
575 | |
576 | lttng_snapshot_add_output_ok "$session_name" "net://localhost" "-n $snapshot_name" | |
577 | lttng_snapshot_record "$session_name" | |
578 | ||
579 | stop_lttng_tracing_ok "$session_name" | |
580 | destroy_lttng_session_ok "$session_name" | |
581 | ||
582 | # When session name is automatic, the actual directory is "auto", not | |
583 | # auto-<datetime>. | |
584 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
585 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$snapshot_name*" | |
586 | else | |
587 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$session_name*/$snapshot_name*" | |
588 | fi | |
589 | ||
590 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
591 | rm -rf "${TRACE_PATH:?}/$session_name" | |
592 | else | |
593 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
594 | fi | |
595 | } | |
596 | ||
597 | function test_ust_uid_streaming_snapshot_add_output_custom_name_custom_output () | |
598 | { | |
599 | local session_name="$1" | |
600 | local grouping="$2" | |
601 | local snapshot_name="this_is_my_snapshot" | |
602 | local custom_output="this/is/my/custom/path" | |
603 | local is_automatic_session=false | |
604 | ||
605 | if [ -z "$session_name" ]; then | |
606 | is_automatic_session=true | |
607 | fi | |
608 | ||
609 | diag "Test UST uid buffer snapshot using 'add-output' with custom snapshot name and custom output path [$grouping][${session_name:-automatic session name}]" | |
610 | ||
611 | create_lttng_session_no_output "$session_name" | |
612 | if [ "$is_automatic_session" = true ]; then | |
613 | get_auto_session_name session_name | |
614 | fi | |
615 | ||
616 | enable_lttng_mmap_overwrite_ust_channel "$session_name" "$CHANNEL_NAME" | |
617 | enable_ust_lttng_event_ok "$session_name" "$EVENT_NAME" "$CHANNEL_NAME" | |
618 | start_lttng_tracing_ok "$session_name" | |
619 | ||
6c4a91d6 | 620 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT |
a9115ebf JR |
621 | |
622 | lttng_snapshot_add_output_ok "$session_name" "net://localhost/$custom_output" "-n $snapshot_name" | |
623 | lttng_snapshot_record "$session_name" | |
624 | ||
625 | stop_lttng_tracing_ok "$session_name" | |
626 | destroy_lttng_session_ok "$session_name" | |
627 | ||
628 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
629 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$session_name/$HOSTNAME-*/$custom_output/$snapshot_name*" | |
630 | else | |
631 | validate_trace "$EVENT_NAME" "$TRACE_PATH/$HOSTNAME/$custom_output/$snapshot_name*" | |
632 | fi | |
633 | ||
634 | if [ "$grouping" = "$GROUP_BY_SESSION" ]; then | |
635 | rm -rf "${TRACE_PATH:?}/$session_name" | |
636 | else | |
637 | rm -rf "${TRACE_PATH:?}/$HOSTNAME" | |
638 | fi | |
639 | } | |
640 | ||
641 | plan_tests $NUM_TESTS | |
642 | ||
643 | print_test_banner "$TEST_DESC" | |
644 | ||
645 | ||
646 | tests=( | |
647 | test_ust_uid_live | |
648 | test_ust_pid_live | |
649 | test_ust_uid_live_custom_output | |
650 | test_ust_uid_streaming | |
651 | test_ust_pid_streaming | |
652 | test_ust_uid_streaming_custom_output | |
653 | test_ust_uid_streaming_rotate | |
654 | test_ust_uid_streaming_rotate_custom_output | |
655 | test_ust_pid_streaming_rotate | |
656 | test_ust_uid_streaming_snapshot | |
657 | test_ust_pid_streaming_snapshot | |
658 | test_ust_uid_streaming_snapshot_add_output_default_name | |
659 | test_ust_uid_streaming_snapshot_add_output_custom_name | |
660 | test_ust_uid_streaming_snapshot_add_output_custom_name_custom_output | |
661 | ) | |
662 | ||
663 | GROUP_BY_SESSION="--group-output-by-session" | |
664 | GROUP_BY_HOSTNAME="--group-output-by-host" | |
665 | ||
666 | grouping_types=( | |
667 | $GROUP_BY_SESSION | |
668 | $GROUP_BY_HOSTNAME | |
669 | ) | |
670 | for fct_test in "${tests[@]}"; | |
671 | do | |
672 | for grouping in "${grouping_types[@]}"; | |
673 | do | |
7539dcec | 674 | TRACE_PATH=$(mktemp --tmpdir -d tmp.test_relayd_grouping_ust_trace_path.XXXXXX) |
a9115ebf JR |
675 | # Set the relayd in --group-output-by-session mode |
676 | start_lttng_relayd "-o $TRACE_PATH $grouping" | |
677 | start_lttng_sessiond | |
678 | ||
679 | name="" | |
680 | # Perform test when session name is generated by the client | |
681 | ${fct_test} "$name" "$grouping" | |
682 | count=$(find "$TRACE_PATH/" -maxdepth 1 -mindepth 1 | wc -l) | |
683 | is "$count" "0" "LTTng-relayd output directory empty" | |
684 | ||
685 | # Perform test when session name is given | |
686 | name="my-session" | |
687 | ${fct_test} "$name" "$grouping" | |
688 | count=$(find "$TRACE_PATH/" -maxdepth 1 -mindepth 1 | wc -l) | |
689 | is "$count" "0" "LTTng-relayd output directory empty" | |
690 | ||
691 | rm -rf "$TRACE_PATH" | |
692 | stop_lttng_relayd | |
693 | stop_lttng_sessiond | |
694 | done | |
695 | done | |
696 |