90c1758e1131fabbf68ad5cba1e87bd1f353d207
[lttng-tools.git] / tests / regression / ust / java-jul / test_java_jul
1 #!/bin/bash
2 #
3 # Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
4 #
5 # SPDX-License-Identifier: GPL-2.0-only
6
7 TEST_DESC="Java JUL support"
8
9 CURDIR=$(dirname $0)/
10 TESTDIR=$CURDIR/../../..
11 NR_ITER=6
12 NR_MSEC_WAIT=1000
13 TESTAPP_NAME="JTestLTTng"
14 TESTAPP_BIN="$TESTAPP_NAME.java"
15 TESTAPP_PATH="$CURDIR/$TESTAPP_NAME"
16 SESSION_NAME="jul"
17 EVENT_NAME="JTestLTTng"
18 EVENT_NAME2="JTestLTTng2"
19 JAVA_CP="$CURDIR:$CLASSPATH"
20
21 NUM_TESTS=195
22
23 source $TESTDIR/utils/utils.sh
24
25 function run_app
26 {
27 local finest_tp=$1
28 local fire_second_tp=$2
29
30 #FIXME: app should have synchro.
31 java -cp $JAVA_CP -Djava.library.path="$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT $finest_tp $fire_second_tp >/dev/null 2>&1
32 }
33
34 function run_app_background
35 {
36 run_app $@ &
37 }
38
39 function enable_jul_loglevel_only()
40 {
41 sess_name=$1
42 event_name="$2"
43 loglevel=$3
44 channel_name=$4
45
46 if [ -z $channel_name ]; then
47 # default channel if none specified
48 chan=""
49 else
50 chan="-c $channel_name"
51 fi
52
53 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" $chan -s $sess_name -j >/dev/null 2>&1
54 ok $? "Enable JUL event $event_name for session $sess_name with loglevel-only $loglevel"
55 }
56
57 function enable_jul_filter()
58 {
59 local sess_name="$1"
60 local event_name="$2"
61 local filter="$3"
62
63 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -j --filter "$filter" >/dev/null 2>&1
64 ok $? "Enable event $event_name with filter $filter for session $sess_name"
65 }
66
67 function enable_jul_filter_loglevel_only()
68 {
69 local sess_name="$1"
70 local event_name="$2"
71 local filter="$3"
72 local loglevel="$4"
73
74 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" -s $sess_name -j --filter "$filter" >/dev/null 2>&1
75 ok $? "Enable event $event_name with filter \"$filter\" and loglevel-only $loglevel for session $sess_name"
76 }
77
78 # MUST set TESTDIR before calling those functions
79
80 function test_jul_before_start ()
81 {
82 local file_sync_after_first=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
83 local file_sync_before_last=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
84
85 diag "Test JUL application BEFORE tracing starts"
86 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
87 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
88
89 # Run 5 times with a 1 second delay
90 run_app_background
91
92 start_lttng_tracing_ok $SESSION_NAME
93
94 touch ${file_sync_before_last}
95
96 # Wait for the applications started in background
97 wait
98
99 stop_lttng_tracing_ok $SESSION_NAME
100 destroy_lttng_session_ok $SESSION_NAME
101
102 rm -f ${file_sync_after_first}
103 rm -f ${file_sync_before_last}
104
105 # Validate test. Expecting all events.
106 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
107 if [ $? -ne 0 ]; then
108 return $?
109 fi
110 }
111
112 function test_jul_after_start ()
113 {
114 diag "Test JUL application AFTER tracing starts"
115
116 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
117 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
118 start_lttng_tracing_ok $SESSION_NAME
119
120 # Run 5 times with a 1 second delay
121 run_app
122
123 stop_lttng_tracing_ok $SESSION_NAME
124 destroy_lttng_session_ok $SESSION_NAME
125
126 # Validate test. Expecting all events.
127 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
128 if [ $? -ne 0 ]; then
129 return $?
130 fi
131 }
132
133 function test_jul_loglevel ()
134 {
135 diag "Test JUL application with loglevel"
136
137 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
138 enable_jul_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "JUL_INFO"
139 start_lttng_tracing_ok $SESSION_NAME
140
141 # Run 5 times with a 1 second delay
142 run_app
143
144 stop_lttng_tracing_ok $SESSION_NAME
145 destroy_lttng_session_ok $SESSION_NAME
146
147 # Validate test. Expecting all events.
148 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
149 if [ $? -ne 0 ]; then
150 return $?
151 fi
152
153 diag "Test JUL applications with lower loglevel"
154
155 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
156 enable_jul_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "JUL_SEVERE"
157 start_lttng_tracing_ok $SESSION_NAME
158
159 # Run 5 times with a 1 second delay
160 run_app
161
162 stop_lttng_tracing_ok $SESSION_NAME
163 destroy_lttng_session_ok $SESSION_NAME
164
165 # Validate test. Expecting 0 events.
166 trace_match_only $EVENT_NAME 0 $TRACE_PATH
167 if [ $? -ne 0 ]; then
168 return $?
169 fi
170
171 diag "Test JUL applications with higher loglevel"
172
173 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
174 enable_jul_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "JUL_FINER"
175 start_lttng_tracing_ok $SESSION_NAME
176
177 # Run 5 times with a 1 second delay
178 run_app
179
180 stop_lttng_tracing_ok $SESSION_NAME
181 destroy_lttng_session_ok $SESSION_NAME
182
183 # Validate test. Expecting all events.
184 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH
185 return $?
186 }
187
188 function test_jul_loglevel_multiple ()
189 {
190 diag "Test JUL application with multiple loglevel"
191
192 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
193 enable_jul_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "JUL_INFO"
194 enable_jul_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "JUL_FINEST"
195 start_lttng_tracing_ok $SESSION_NAME
196
197 # Run 5 times with a 1 second delay and fire two TP.
198 run_app 1
199
200 stop_lttng_tracing_ok $SESSION_NAME
201 destroy_lttng_session_ok $SESSION_NAME
202
203 # Validate test. Expecting all events times two.
204 trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH
205 if [ $? -ne 0 ]; then
206 return $?
207 fi
208
209 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
210 enable_jul_lttng_event_loglevel $SESSION_NAME '*' "JUL_INFO"
211 enable_jul_lttng_event_loglevel $SESSION_NAME '*' "JUL_FINEST"
212 start_lttng_tracing_ok $SESSION_NAME
213
214 # Run 5 times with a 1 second delay and fire two TP.
215 run_app 1
216
217 stop_lttng_tracing_ok $SESSION_NAME
218 destroy_lttng_session_ok $SESSION_NAME
219
220 # Validate test. Expecting all events times two.
221 trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH
222 if [ $? -ne 0 ]; then
223 return $?
224 fi
225 }
226
227 function test_jul_multi_session_loglevel()
228 {
229 diag "Test JUL with multiple session"
230
231 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
232 enable_jul_loglevel_only $SESSION_NAME-1 '*' "JUL_INFO"
233 start_lttng_tracing_ok $SESSION_NAME-1
234
235 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
236 enable_jul_loglevel_only $SESSION_NAME-2 '*' "JUL_FINEST"
237 start_lttng_tracing_ok $SESSION_NAME-2
238
239 # Run 5 times with a 1 second delay and fire second TP.
240 run_app 1 1
241
242 stop_lttng_tracing_ok $SESSION_NAME-1
243 stop_lttng_tracing_ok $SESSION_NAME-2
244 destroy_lttng_session_ok $SESSION_NAME-1
245 destroy_lttng_session_ok $SESSION_NAME-2
246
247 # Expecting 6 events being the main event plus the second tp.
248 trace_match_only $EVENT_NAME $(($NR_ITER + 1)) $TRACE_PATH/$SESSION_NAME-1
249 if [ $? -ne 0 ]; then
250 return $?
251 fi
252
253 # Expectin 5 events being the finest TP.
254 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2
255 if [ $? -ne 0 ]; then
256 return $?
257 fi
258 }
259
260 function test_jul_multi_session_disable()
261 {
262 diag "Test JUL with multiple session with disabled event"
263
264 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
265 enable_jul_lttng_event $SESSION_NAME-1 $EVENT_NAME
266 enable_jul_lttng_event $SESSION_NAME-1 $EVENT_NAME2
267 disable_jul_lttng_event $SESSION_NAME-1 $EVENT_NAME
268 start_lttng_tracing_ok $SESSION_NAME-1
269
270 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
271 enable_jul_lttng_event $SESSION_NAME-2 $EVENT_NAME2
272 start_lttng_tracing_ok $SESSION_NAME-2
273
274 # Run 5 times with a 1 second delay and fire second TP.
275 run_app 0 1
276
277 stop_lttng_tracing_ok $SESSION_NAME-1
278 stop_lttng_tracing_ok $SESSION_NAME-2
279 destroy_lttng_session_ok $SESSION_NAME-1
280 destroy_lttng_session_ok $SESSION_NAME-2
281
282 # Validate test. Expecting one event of the second TP.
283 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1
284 if [ $? -ne 0 ]; then
285 return $?
286 fi
287
288 # Validate test. Expecting one event of the second TP.
289 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
290 if [ $? -ne 0 ]; then
291 return $?
292 fi
293 }
294
295 function test_jul_multi_session_disable_wildcard()
296 {
297 diag "Test JUL with multiple session with disabled wildcard event"
298
299 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
300 enable_jul_lttng_event $SESSION_NAME-1 '*'
301
302 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
303 enable_jul_lttng_event $SESSION_NAME-2 '*'
304
305 disable_jul_lttng_event $SESSION_NAME-1 '*'
306
307 start_lttng_tracing_ok $SESSION_NAME-1
308 start_lttng_tracing_ok $SESSION_NAME-2
309
310 run_app
311
312 stop_lttng_tracing_ok $SESSION_NAME-1
313 stop_lttng_tracing_ok $SESSION_NAME-2
314 destroy_lttng_session_ok $SESSION_NAME-1
315 destroy_lttng_session_ok $SESSION_NAME-2
316
317 # Validate test. Expecting NO event of the first TP.
318 trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1
319 if [ $? -ne 0 ]; then
320 return $?
321 fi
322
323 # Validate test. Expecting all events of the first TP.
324 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2
325 if [ $? -ne 0 ]; then
326 return $?
327 fi
328 }
329
330 function test_jul_multi_session_disable_wildcard_begin()
331 {
332 ev_name='*LTTng'
333 diag "Test JUL with multiple session with disabled wildcard (at the beginning) event"
334
335 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
336 enable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
337
338 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
339 enable_jul_lttng_event $SESSION_NAME-2 "$ev_name"
340
341 disable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
342
343 start_lttng_tracing_ok $SESSION_NAME-1
344 start_lttng_tracing_ok $SESSION_NAME-2
345
346 run_app 0 1
347
348 stop_lttng_tracing_ok $SESSION_NAME-1
349 stop_lttng_tracing_ok $SESSION_NAME-2
350 destroy_lttng_session_ok $SESSION_NAME-1
351 destroy_lttng_session_ok $SESSION_NAME-2
352
353 # Validate test. Expecting NO event of the first TP.
354 trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1
355 if [ $? -ne 0 ]; then
356 return $?
357 fi
358
359 # Validate test. Expecting all events of the first TP.
360 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2
361 if [ $? -ne 0 ]; then
362 return $?
363 fi
364 }
365
366 function test_jul_multi_session_disable_wildcard_middle()
367 {
368 ev_name='J*LTTng'
369 diag "Test JUL with multiple session with disabled wildcard (at the middle) event"
370
371 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
372 enable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
373
374 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
375 enable_jul_lttng_event $SESSION_NAME-2 "$ev_name"
376
377 disable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
378
379 start_lttng_tracing_ok $SESSION_NAME-1
380 start_lttng_tracing_ok $SESSION_NAME-2
381
382 run_app 0 1
383
384 stop_lttng_tracing_ok $SESSION_NAME-1
385 stop_lttng_tracing_ok $SESSION_NAME-2
386 destroy_lttng_session_ok $SESSION_NAME-1
387 destroy_lttng_session_ok $SESSION_NAME-2
388
389 # Validate test. Expecting NO event of the first TP.
390 trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1
391 if [ $? -ne 0 ]; then
392 return $?
393 fi
394
395 # Validate test. Expecting all events of the first TP.
396 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2
397 if [ $? -ne 0 ]; then
398 return $?
399 fi
400 }
401
402 function test_jul_multi_session_disable_wildcard_end()
403 {
404 ev_name='JTestLTT*'
405 diag "Test JUL with multiple session with disabled wildcard (at the end) event"
406
407 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
408 enable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
409
410 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
411 enable_jul_lttng_event $SESSION_NAME-2 "$ev_name"
412
413 disable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
414
415 start_lttng_tracing_ok $SESSION_NAME-1
416 start_lttng_tracing_ok $SESSION_NAME-2
417
418 run_app 0 1
419
420 stop_lttng_tracing_ok $SESSION_NAME-1
421 stop_lttng_tracing_ok $SESSION_NAME-2
422 destroy_lttng_session_ok $SESSION_NAME-1
423 destroy_lttng_session_ok $SESSION_NAME-2
424
425 # Validate test. Expecting NO event of the first TP.
426 trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1
427 if [ $? -ne 0 ]; then
428 return $?
429 fi
430
431 # Validate test. Expecting all events of the first TP.
432 trace_matches $EVENT_NAME $(( $NR_ITER + 1 )) $TRACE_PATH/$SESSION_NAME-2
433 if [ $? -ne 0 ]; then
434 return $?
435 fi
436
437 trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
438 if [ $? -ne 0 ]; then
439 return $?
440 fi
441 }
442
443 function test_jul_disable_all()
444 {
445 diag "Test JUL with multiple session with disabled all event"
446
447 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
448 enable_jul_lttng_event $SESSION_NAME '*'
449 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
450 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
451
452 disable_jul_lttng_event $SESSION_NAME -a
453
454 start_lttng_tracing_ok $SESSION_NAME
455
456 run_app 0 1
457
458 stop_lttng_tracing_ok $SESSION_NAME
459 destroy_lttng_session_ok $SESSION_NAME
460
461 # Validate test. Expecting NO event of the first TP and second TP.
462 trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME
463 trace_match_only $EVENT_NAME2 0 $TRACE_PATH/$SESSION_NAME
464 if [ $? -ne 0 ]; then
465 return $?
466 fi
467 }
468
469 function test_jul_multi_session()
470 {
471 diag "Test JUL with multiple session"
472
473 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
474 enable_jul_lttng_event $SESSION_NAME-1 $EVENT_NAME
475 start_lttng_tracing_ok $SESSION_NAME-1
476
477 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
478 enable_jul_lttng_event $SESSION_NAME-2 $EVENT_NAME2
479 start_lttng_tracing_ok $SESSION_NAME-2
480
481 # Run 5 times with a 1 second delay and fire second TP.
482 run_app 0 1
483
484 stop_lttng_tracing_ok $SESSION_NAME-1
485 stop_lttng_tracing_ok $SESSION_NAME-2
486 destroy_lttng_session_ok $SESSION_NAME-1
487 destroy_lttng_session_ok $SESSION_NAME-2
488
489 # Validate test. Expecting all events of first TP
490 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1
491 if [ $? -ne 0 ]; then
492 return $?
493 fi
494
495 # Validate test. Expecting one event of the second TP.
496 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
497 if [ $? -ne 0 ]; then
498 return $?
499 fi
500 }
501
502 function test_jul_destroy_session()
503 {
504 diag "Test JUL two session with destroy"
505
506 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/first-sess
507 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
508 start_lttng_tracing_ok $SESSION_NAME
509
510 # Run 5 times with a 1 second delay
511 run_app_background 0 1
512
513 # Wait for the applications started in background
514 wait
515
516 stop_lttng_tracing_ok $SESSION_NAME
517 destroy_lttng_session_ok $SESSION_NAME
518
519 # Validate test. Expecting at least one event num 1
520 validate_trace $EVENT_NAME $TRACE_PATH/first-sess
521 if [ $? -ne 0 ]; then
522 return $?
523 fi
524
525 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/second-sess
526 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
527 start_lttng_tracing_ok $SESSION_NAME
528
529 # Run 5 times with a 1 second delay
530 run_app_background 0 1
531
532 # Wait for the applications started in background
533 wait
534
535 stop_lttng_tracing_ok $SESSION_NAME
536 destroy_lttng_session_ok $SESSION_NAME
537
538 # Validate test. Expecting only one event num 2
539 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/second-sess
540 if [ $? -ne 0 ]; then
541 return $?
542 fi
543 }
544
545 function test_jul_filtering()
546 {
547 diag "Test JUL filtering"
548
549 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
550 # Enable all event with a filter.
551 enable_jul_filter $SESSION_NAME '*' 'msg == "JUL second logger fired"'
552 start_lttng_tracing_ok $SESSION_NAME
553
554 # Run 5 times with a 1 second delay and fire second TP.
555 run_app 0 1
556
557 stop_lttng_tracing_ok $SESSION_NAME
558 destroy_lttng_session_ok $SESSION_NAME
559
560 # Validate test. Expecting one event of the second TP only.
561 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
562 if [ $? -ne 0 ]; then
563 return $?
564 fi
565
566 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
567 # Enable first Logger but filter msg payload for the INFO one while
568 # triggering the finest and second TP.
569 enable_jul_filter $SESSION_NAME $EVENT_NAME 'msg == "JUL tp fired!"'
570 start_lttng_tracing_ok $SESSION_NAME
571
572 # Run 5 times with a 1 second delay, fire finest and second TP.
573 run_app 1 1
574
575 stop_lttng_tracing_ok $SESSION_NAME
576 destroy_lttng_session_ok $SESSION_NAME
577
578 # Validate test. Expecting NR_ITER event of the main INFO tp.
579 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME
580 if [ $? -ne 0 ]; then
581 return $?
582 fi
583 }
584
585 function test_jul_disable()
586 {
587 diag "Test JUL disable event"
588
589 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
590 # Enable all event with a filter.
591 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
592 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
593 disable_jul_lttng_event $SESSION_NAME $EVENT_NAME
594 start_lttng_tracing_ok $SESSION_NAME
595
596 # Run 5 times with a 1 second delay and fire second TP.
597 run_app 0 1
598
599 stop_lttng_tracing_ok $SESSION_NAME
600 destroy_lttng_session_ok $SESSION_NAME
601
602 # Validate test. Expecting one event of the second TP only.
603 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
604 if [ $? -ne 0 ]; then
605 return $?
606 fi
607 }
608
609 function test_jul_disable_enable()
610 {
611 diag "Test JUL disable event followed by an enable"
612
613 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
614 # Enable all event with a filter.
615 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
616 disable_jul_lttng_event $SESSION_NAME $EVENT_NAME
617 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
618 start_lttng_tracing_ok $SESSION_NAME
619
620 # Run 5 times with a 1 second delay and fire second TP.
621 run_app 0 1
622
623 stop_lttng_tracing_ok $SESSION_NAME
624 destroy_lttng_session_ok $SESSION_NAME
625
626 # Validate test. Expecting NR_ITER event of the main INFO tp.
627 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME
628 if [ $? -ne 0 ]; then
629 return $?
630 fi
631 }
632
633 function test_jul_filter_loglevel()
634 {
635 local BOGUS_EVENT_NAME="not_a_real_event"
636 local FILTER="int_loglevel > 700 || int_loglevel < 700"
637 local ALL_EVENTS="."
638
639 diag "Test JUL a filter with a loglevel"
640
641 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
642 # Enable an event with a filter and the loglevel-only option.
643 enable_jul_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" JUL_CONFIG
644 disable_jul_lttng_event $SESSION_NAME $BOGUS_EVENT_NAME
645 enable_jul_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" JUL_CONFIG
646 start_lttng_tracing_ok $SESSION_NAME
647
648 # Run 5 times with a 1 second delay and fire second TP.
649 run_app 0 1
650
651 stop_lttng_tracing_ok $SESSION_NAME
652 destroy_lttng_session_ok $SESSION_NAME
653
654 # Validate test. Expecting no events.
655 trace_match_only $ALL_EVENTS 0 $TRACE_PATH/$SESSION_NAME
656 if [ $? -ne 0 ]; then
657 return $?
658 fi
659 }
660
661 plan_tests $NUM_TESTS
662
663 print_test_banner "$TEST_DESC"
664
665 bail_out_if_no_babeltrace
666
667 if [ ! -f "$TESTAPP_PATH.class" ]; then
668 withapp=0
669 else
670 withapp=1
671 fi
672
673 skip $withapp "JUL support is needed. Skipping all tests." $NUM_TESTS ||
674 {
675 start_lttng_sessiond
676
677 tests=(
678 test_jul_multi_session_disable_wildcard_begin
679 test_jul_multi_session_disable_wildcard_middle
680 test_jul_multi_session_disable_wildcard_end
681 test_jul_multi_session_disable_wildcard
682 test_jul_multi_session_disable
683 test_jul_disable
684 test_jul_disable_enable
685 test_jul_disable_all
686 test_jul_filtering
687 test_jul_multi_session_loglevel
688 test_jul_destroy_session
689 test_jul_loglevel
690 test_jul_loglevel_multiple
691 test_jul_before_start
692 test_jul_after_start
693 test_jul_multi_session
694 test_jul_filter_loglevel
695 )
696
697 for fct_test in ${tests[@]};
698 do
699 TRACE_PATH=$(mktemp --tmpdir -d tmp.test_java_jul_trace_path.XXXXXX)
700
701 ${fct_test}
702 if [ $? -ne 0 ]; then
703 break;
704 fi
705 rm -rf $TRACE_PATH
706 done
707
708 stop_lttng_sessiond
709 }
This page took 0.070521 seconds and 4 git commands to generate.