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