Bump URCU dependency to 0.14
[lttng-tools.git] / tests / regression / ust / java-log4j / test_java_log4j
CommitLineData
504d4ace
DG
1#!/bin/bash
2#
9d16b343 3# Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
504d4ace 4#
9d16b343 5# SPDX-License-Identifier: GPL-2.0-only
504d4ace
DG
6
7TEST_DESC="Java LOG4J support"
8
0fd2fd15 9CURDIR=$(dirname "$0")/
504d4ace 10TESTDIR=$CURDIR/../../..
0fd2fd15 11
504d4ace 12NR_ITER=6
0fd2fd15
MJ
13NR_MSEC_WAIT=100
14
15TESTAPP_NAME="JTestLTTngLog4j"
504d4ace 16TESTAPP_PATH="$CURDIR/$TESTAPP_NAME"
0fd2fd15 17
504d4ace
DG
18SESSION_NAME="log4j"
19EVENT_NAME="log4j-event"
20EVENT_NAME2="log4j-event-2"
0fd2fd15 21
0b7af945 22JAVA_CP="$CURDIR:$CLASSPATH"
504d4ace 23
0fd2fd15 24NUM_TESTS=196
504d4ace 25
0fd2fd15
MJ
26# shellcheck source=../../../utils/utils.sh
27source "$TESTDIR/utils/utils.sh"
504d4ace
DG
28
29function run_app
30{
31 local debug_tp=$1
32 local fire_second_tp=$2
33
0fd2fd15
MJ
34 if [ "$debug_tp" = "" ]; then
35 debug_tp=0
36 fi
504d4ace 37
0fd2fd15
MJ
38 if [ "$fire_second_tp" = "" ]; then
39 fire_second_tp=0
504d4ace
DG
40 fi
41
0fd2fd15
MJ
42 # FIXME: test app should have synchro.
43 diag "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"
44 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" >"$OUTPUT_DEST" 2>"$ERROR_OUTPUT_DEST"
504d4ace
DG
45}
46
0fd2fd15 47function run_app_background
504d4ace 48{
0fd2fd15 49 run_app "${@}" &
504d4ace
DG
50}
51
504d4ace
DG
52
53# MUST set TESTDIR before calling those functions
54
55function test_log4j_before_start ()
56{
0fd2fd15
MJ
57 local file_sync_after_first
58 local file_sync_before_last
59
60 file_sync_after_first=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
61 file_sync_before_last=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
5fcaccbc 62
504d4ace 63 diag "Test LOG4J application BEFORE tracing starts"
0fd2fd15 64 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
504d4ace
DG
65 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
66
67 # Run 5 times with a 1 second delay
68 run_app_background
69
e563bbdb 70 start_lttng_tracing_ok $SESSION_NAME
504d4ace 71
0fd2fd15 72 touch "${file_sync_before_last}"
5fcaccbc 73
504d4ace 74 # Wait for the applications started in background
0fc2834c 75 wait
504d4ace 76
96340a01 77 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 78 destroy_lttng_session_ok $SESSION_NAME
504d4ace 79
0fd2fd15
MJ
80 rm -f "${file_sync_after_first}"
81 rm -f "${file_sync_before_last}"
5fcaccbc 82
504d4ace 83 # Validate test. Expecting all events.
0fd2fd15 84 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"
504d4ace
DG
85}
86
87function test_log4j_after_start ()
88{
89 diag "Test LOG4J application AFTER tracing starts"
90
0fd2fd15 91 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
504d4ace 92 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 93 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
94
95 # Run 5 times with a 1 second delay
96 run_app
97
96340a01 98 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 99 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
100
101 # Validate test. Expecting all events.
0fd2fd15 102 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"
504d4ace
DG
103}
104
105function test_log4j_loglevel ()
106{
107 diag "Test LOG4J application with loglevel"
108
0fd2fd15 109 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
504d4ace 110 enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_INFO"
e563bbdb 111 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
112
113 # Run 5 times with a 1 second delay
114 run_app
115
96340a01 116 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 117 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
118
119 # Validate test. Expecting all events.
0fd2fd15 120 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"
504d4ace
DG
121
122 diag "Test LOG4J applications with lower loglevel"
123
0fd2fd15 124 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
504d4ace 125 enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_FATAL"
e563bbdb 126 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
127
128 # Run 5 times with a 1 second delay
129 run_app
130
96340a01 131 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 132 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
133
134 # Validate test. Expecting 0 events.
0fd2fd15 135 trace_match_only $EVENT_NAME 0 "$TRACE_PATH"
504d4ace
DG
136
137 diag "Test LOG4J applications with higher loglevel"
138
0fd2fd15 139 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
504d4ace 140 enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_TRACE"
e563bbdb 141 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
142
143 # Run 5 times with a 1 second delay
144 run_app
145
96340a01 146 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 147 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
148
149 # Validate test. Expecting all events.
0fd2fd15 150 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"
504d4ace
DG
151}
152
153function test_log4j_loglevel_multiple ()
154{
155 diag "Test LOG4J application with multiple loglevel"
156
0fd2fd15 157 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
504d4ace
DG
158 enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_INFO"
159 enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_DEBUG"
e563bbdb 160 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
161
162 # Run 5 times with a 1 second delay and fire two TP.
163 run_app 1
164
96340a01 165 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 166 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
167
168 # Validate test. Expecting all events times two.
0fd2fd15 169 trace_match_only $EVENT_NAME $((NR_ITER * 2)) "$TRACE_PATH"
504d4ace 170
0fd2fd15 171 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
504d4ace
DG
172 enable_log4j_lttng_event_loglevel $SESSION_NAME '*' "LOG4J_INFO"
173 enable_log4j_lttng_event_loglevel $SESSION_NAME '*' "LOG4J_DEBUG"
e563bbdb 174 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
175
176 # Run 5 times with a 1 second delay and fire two TP.
177 run_app 1
178
96340a01 179 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 180 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
181
182 # Validate test. Expecting all events times two.
0fd2fd15 183 trace_match_only $EVENT_NAME $((NR_ITER * 2)) "$TRACE_PATH"
504d4ace
DG
184}
185
186function test_log4j_multi_session_loglevel()
187{
188 diag "Test LOG4J with multiple session"
189
0fd2fd15
MJ
190 create_lttng_session_ok $SESSION_NAME-1 "$TRACE_PATH"/$SESSION_NAME-1
191 enable_log4j_lttng_event_loglevel_only $SESSION_NAME-1 '*' "LOG4J_INFO"
e563bbdb 192 start_lttng_tracing_ok $SESSION_NAME-1
504d4ace 193
0fd2fd15
MJ
194 create_lttng_session_ok $SESSION_NAME-2 "$TRACE_PATH"/$SESSION_NAME-2
195 enable_log4j_lttng_event_loglevel_only $SESSION_NAME-2 '*' "LOG4J_DEBUG"
e563bbdb 196 start_lttng_tracing_ok $SESSION_NAME-2
504d4ace
DG
197
198 # Run 5 times with a 1 second delay and fire second TP.
199 run_app 1 1
200
96340a01
JR
201 stop_lttng_tracing_ok $SESSION_NAME-1
202 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
203 destroy_lttng_session_ok $SESSION_NAME-1
204 destroy_lttng_session_ok $SESSION_NAME-2
504d4ace
DG
205
206 # Expecting 6 events being the main event plus the second tp.
0fd2fd15 207 trace_match_only $EVENT_NAME $((NR_ITER + 1)) "$TRACE_PATH"/$SESSION_NAME-1
504d4ace
DG
208
209 # Expectin 5 events being the debug TP.
0fd2fd15 210 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"/$SESSION_NAME-2
504d4ace
DG
211}
212
213function test_log4j_multi_session_disable()
214{
215 diag "Test LOG4J with multiple session with disabled event"
216
0fd2fd15 217 create_lttng_session_ok $SESSION_NAME-1 "$TRACE_PATH"/$SESSION_NAME-1
504d4ace
DG
218 enable_log4j_lttng_event $SESSION_NAME-1 $EVENT_NAME
219 enable_log4j_lttng_event $SESSION_NAME-1 $EVENT_NAME2
220 disable_log4j_lttng_event $SESSION_NAME-1 $EVENT_NAME
e563bbdb 221 start_lttng_tracing_ok $SESSION_NAME-1
504d4ace 222
0fd2fd15 223 create_lttng_session_ok $SESSION_NAME-2 "$TRACE_PATH"/$SESSION_NAME-2
504d4ace 224 enable_log4j_lttng_event $SESSION_NAME-2 $EVENT_NAME2
e563bbdb 225 start_lttng_tracing_ok $SESSION_NAME-2
504d4ace
DG
226
227 # Run 5 times with a 1 second delay and fire second TP.
228 run_app 0 1
229
96340a01
JR
230 stop_lttng_tracing_ok $SESSION_NAME-1
231 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
232 destroy_lttng_session_ok $SESSION_NAME-1
233 destroy_lttng_session_ok $SESSION_NAME-2
504d4ace
DG
234
235 # Validate test. Expecting one event of the second TP.
0fd2fd15 236 trace_match_only $EVENT_NAME2 1 "$TRACE_PATH"/$SESSION_NAME-1
504d4ace
DG
237
238 # Validate test. Expecting one event of the second TP.
0fd2fd15 239 trace_match_only $EVENT_NAME2 1 "$TRACE_PATH"/$SESSION_NAME-2
504d4ace
DG
240}
241
242function test_log4j_multi_session_disable_wildcard()
243{
244 diag "Test LOG4J with multiple session with disabled wildcard event"
245
0fd2fd15 246 create_lttng_session_ok $SESSION_NAME-1 "$TRACE_PATH"/$SESSION_NAME-1
504d4ace
DG
247 enable_log4j_lttng_event $SESSION_NAME-1 '*'
248
0fd2fd15 249 create_lttng_session_ok $SESSION_NAME-2 "$TRACE_PATH"/$SESSION_NAME-2
504d4ace
DG
250 enable_log4j_lttng_event $SESSION_NAME-2 '*'
251
252 disable_log4j_lttng_event $SESSION_NAME-1 '*'
253
e563bbdb
JR
254 start_lttng_tracing_ok $SESSION_NAME-1
255 start_lttng_tracing_ok $SESSION_NAME-2
504d4ace
DG
256
257 run_app
258
96340a01
JR
259 stop_lttng_tracing_ok $SESSION_NAME-1
260 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
261 destroy_lttng_session_ok $SESSION_NAME-1
262 destroy_lttng_session_ok $SESSION_NAME-2
504d4ace
DG
263
264 # Validate test. Expecting NO event of the first TP.
0fd2fd15 265 trace_match_only $EVENT_NAME 0 "$TRACE_PATH"/$SESSION_NAME-1
504d4ace
DG
266
267 # Validate test. Expecting all events of the first TP.
0fd2fd15 268 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"/$SESSION_NAME-2
504d4ace
DG
269}
270
42aad3d2
PP
271function test_log4j_multi_session_disable_wildcard_begin()
272{
273 ev_name='*-event'
274 diag "Test LOG4J with multiple session with disabled wildcard (at the beginning) event"
275
0fd2fd15 276 create_lttng_session_ok $SESSION_NAME-1 "$TRACE_PATH"/$SESSION_NAME-1
42aad3d2
PP
277 enable_log4j_lttng_event $SESSION_NAME-1 "$ev_name"
278
0fd2fd15 279 create_lttng_session_ok $SESSION_NAME-2 "$TRACE_PATH"/$SESSION_NAME-2
42aad3d2
PP
280 enable_log4j_lttng_event $SESSION_NAME-2 "$ev_name"
281
282 disable_log4j_lttng_event $SESSION_NAME-1 "$ev_name"
283
284 start_lttng_tracing_ok $SESSION_NAME-1
285 start_lttng_tracing_ok $SESSION_NAME-2
286
287 run_app 0 1
288
289 stop_lttng_tracing_ok $SESSION_NAME-1
290 stop_lttng_tracing_ok $SESSION_NAME-2
291 destroy_lttng_session_ok $SESSION_NAME-1
292 destroy_lttng_session_ok $SESSION_NAME-2
293
294 # Validate test. Expecting NO event of the first TP.
0fd2fd15 295 trace_match_only $EVENT_NAME 0 "$TRACE_PATH"/$SESSION_NAME-1
42aad3d2
PP
296
297 # Validate test. Expecting all events of the first TP.
0fd2fd15 298 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"/$SESSION_NAME-2
42aad3d2
PP
299}
300
301function test_log4j_multi_session_disable_wildcard_middle()
302{
303 ev_name='log*nt'
304 diag "Test LOG4J with multiple session with disabled wildcard (at the middle) event"
305
0fd2fd15 306 create_lttng_session_ok $SESSION_NAME-1 "$TRACE_PATH"/$SESSION_NAME-1
42aad3d2
PP
307 enable_log4j_lttng_event $SESSION_NAME-1 "$ev_name"
308
0fd2fd15 309 create_lttng_session_ok $SESSION_NAME-2 "$TRACE_PATH"/$SESSION_NAME-2
42aad3d2
PP
310 enable_log4j_lttng_event $SESSION_NAME-2 "$ev_name"
311
312 disable_log4j_lttng_event $SESSION_NAME-1 "$ev_name"
313
314 start_lttng_tracing_ok $SESSION_NAME-1
315 start_lttng_tracing_ok $SESSION_NAME-2
316
317 run_app 0 1
318
319 stop_lttng_tracing_ok $SESSION_NAME-1
320 stop_lttng_tracing_ok $SESSION_NAME-2
321 destroy_lttng_session_ok $SESSION_NAME-1
322 destroy_lttng_session_ok $SESSION_NAME-2
323
324 # Validate test. Expecting NO event of the first TP.
0fd2fd15 325 trace_match_only $EVENT_NAME 0 "$TRACE_PATH"/$SESSION_NAME-1
42aad3d2
PP
326
327 # Validate test. Expecting all events of the first TP.
0fd2fd15 328 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"/$SESSION_NAME-2
42aad3d2
PP
329}
330
331function test_log4j_multi_session_disable_wildcard_end()
332{
333 ev_name='log4j-ev*'
334 diag "Test LOG4J with multiple session with disabled wildcard (at the end) event"
335
0fd2fd15 336 create_lttng_session_ok $SESSION_NAME-1 "$TRACE_PATH"/$SESSION_NAME-1
42aad3d2
PP
337 enable_log4j_lttng_event $SESSION_NAME-1 "$ev_name"
338
0fd2fd15 339 create_lttng_session_ok $SESSION_NAME-2 "$TRACE_PATH"/$SESSION_NAME-2
42aad3d2
PP
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.
0fd2fd15 355 trace_match_only $EVENT_NAME 0 "$TRACE_PATH"/$SESSION_NAME-1
42aad3d2
PP
356
357 # Validate test. Expecting all events of the first TP.
0fd2fd15 358 trace_matches $EVENT_NAME $(( NR_ITER + 1 )) "$TRACE_PATH"/$SESSION_NAME-2
42aad3d2 359
0fd2fd15 360 trace_matches $EVENT_NAME2 1 "$TRACE_PATH"/$SESSION_NAME-2
42aad3d2
PP
361}
362
504d4ace
DG
363function test_log4j_disable_all()
364{
365 diag "Test LOG4J with multiple session with disabled all event"
366
0fd2fd15 367 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
368 enable_log4j_lttng_event $SESSION_NAME '*'
369 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
370 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME2
371
c364f6e0 372 disable_log4j_lttng_event $SESSION_NAME -a
504d4ace 373
e563bbdb 374 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
375
376 run_app 0 1
377
96340a01 378 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 379 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
380
381 # Validate test. Expecting NO event of the first TP and second TP.
0fd2fd15
MJ
382 trace_match_only $EVENT_NAME 0 "$TRACE_PATH"/$SESSION_NAME
383 trace_match_only $EVENT_NAME2 0 "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
384}
385
386function test_log4j_multi_session()
387{
388 diag "Test LOG4J with multiple session"
389
0fd2fd15 390 create_lttng_session_ok $SESSION_NAME-1 "$TRACE_PATH"/$SESSION_NAME-1
504d4ace 391 enable_log4j_lttng_event $SESSION_NAME-1 $EVENT_NAME
e563bbdb 392 start_lttng_tracing_ok $SESSION_NAME-1
504d4ace 393
0fd2fd15 394 create_lttng_session_ok $SESSION_NAME-2 "$TRACE_PATH"/$SESSION_NAME-2
504d4ace 395 enable_log4j_lttng_event $SESSION_NAME-2 $EVENT_NAME2
e563bbdb 396 start_lttng_tracing_ok $SESSION_NAME-2
504d4ace
DG
397
398 # Run 5 times with a 1 second delay and fire second TP.
399 run_app 0 1
400
96340a01
JR
401 stop_lttng_tracing_ok $SESSION_NAME-1
402 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
403 destroy_lttng_session_ok $SESSION_NAME-1
404 destroy_lttng_session_ok $SESSION_NAME-2
504d4ace
DG
405
406 # Validate test. Expecting all events of first TP
0fd2fd15 407 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"/$SESSION_NAME-1
504d4ace
DG
408
409 # Validate test. Expecting one event of the second TP.
0fd2fd15 410 trace_match_only $EVENT_NAME2 1 "$TRACE_PATH"/$SESSION_NAME-2
504d4ace
DG
411}
412
413function test_log4j_destroy_session()
414{
415 diag "Test LOG4J two session with destroy"
416
0fd2fd15 417 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"/first-sess
504d4ace 418 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 419 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
420
421 # Run 5 times with a 1 second delay
422 run_app_background 0 1
0fc2834c
MD
423 # Wait for the applications started in background
424 wait
504d4ace 425
96340a01 426 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 427 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
428
429 # Validate test. Expecting at least one event num 1
0fd2fd15 430 validate_trace $EVENT_NAME "$TRACE_PATH"/first-sess
504d4ace 431
0fd2fd15 432 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"/second-sess
504d4ace 433 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME2
e563bbdb 434 start_lttng_tracing_ok $SESSION_NAME
504d4ace 435
0fc2834c
MD
436 # Run 5 times with a 1 second delay
437 run_app_background 0 1
504d4ace 438 # Wait for the applications started in background
0fc2834c 439 wait
504d4ace 440
96340a01 441 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 442 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
443
444 # Validate test. Expecting only one event num 2
0fd2fd15 445 trace_match_only $EVENT_NAME2 1 "$TRACE_PATH"/second-sess
504d4ace
DG
446}
447
448function test_log4j_filtering()
449{
450 diag "Test LOG4J filtering"
451
0fd2fd15 452 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"/$SESSION_NAME
504d4ace 453 # Enable all event with a filter.
0fd2fd15 454 enable_log4j_lttng_event_filter $SESSION_NAME '*' 'msg == "LOG4J second logger fired"'
e563bbdb 455 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
456
457 # Run 5 times with a 1 second delay and fire second TP.
458 run_app 0 1
459
96340a01 460 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 461 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
462
463 # Validate test. Expecting one event of the second TP only.
0fd2fd15 464 trace_match_only $EVENT_NAME2 1 "$TRACE_PATH"/$SESSION_NAME
504d4ace 465
0fd2fd15 466 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
467 # Enable first Logger but filter msg payload for the INFO one while
468 # triggering the debug and second TP.
0fd2fd15 469 enable_log4j_lttng_event_filter $SESSION_NAME $EVENT_NAME 'msg == "LOG4J tp fired!"'
e563bbdb 470 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
471
472 # Run 5 times with a 1 second delay, fire debug and second TP.
473 run_app 1 1
474
96340a01 475 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 476 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
477
478 # Validate test. Expecting NR_ITER event of the main INFO tp.
0fd2fd15 479 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
480}
481
482function test_log4j_disable()
483{
484 diag "Test LOG4J disable event"
485
0fd2fd15 486 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
487 # Enable all event with a filter.
488 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
489 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME2
490 disable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 491 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
492
493 # Run 5 times with a 1 second delay and fire second TP.
494 run_app 0 1
495
96340a01 496 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 497 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
498
499 # Validate test. Expecting one event of the second TP only.
0fd2fd15 500 trace_match_only $EVENT_NAME2 1 "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
501}
502
503function test_log4j_disable_enable()
504{
505 diag "Test LOG4J disable event followed by an enable"
506
0fd2fd15 507 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
508 # Enable all event with a filter.
509 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
510 disable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
511 enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 512 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
513
514 # Run 5 times with a 1 second delay and fire second TP.
515 run_app 0 1
516
96340a01 517 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 518 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
519
520 # Validate test. Expecting NR_ITER event of the main INFO tp.
0fd2fd15 521 trace_match_only $EVENT_NAME $NR_ITER "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
522}
523
524function test_log4j_filter_loglevel()
525{
526 local BOGUS_EVENT_NAME="not_a_real_event"
527 local FILTER="int_loglevel > 700 || int_loglevel < 700"
528 local ALL_EVENTS="."
529
530 diag "Test LOG4J a filter with a loglevel"
531
0fd2fd15 532 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"/$SESSION_NAME
504d4ace 533 # Enable an event with a filter and the loglevel-only option.
0fd2fd15 534 enable_log4j_lttng_event_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" LOG4J_INFO
504d4ace 535 disable_log4j_lttng_event $SESSION_NAME $BOGUS_EVENT_NAME
0fd2fd15 536 enable_log4j_lttng_event_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" LOG4J_INFO
e563bbdb 537 start_lttng_tracing_ok $SESSION_NAME
504d4ace
DG
538
539 # Run 5 times with a 1 second delay and fire second TP.
540 run_app 0 1
541
96340a01 542 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 543 destroy_lttng_session_ok $SESSION_NAME
504d4ace
DG
544
545 # Validate test. Expecting no events.
0fd2fd15 546 trace_match_only $ALL_EVENTS 0 "$TRACE_PATH"/$SESSION_NAME
504d4ace
DG
547}
548
549plan_tests $NUM_TESTS
550
551print_test_banner "$TEST_DESC"
552
c125de8f
FD
553bail_out_if_no_babeltrace
554
0fd2fd15
MJ
555test -f "$TESTAPP_PATH.class"
556ok $? "Testapp '$TESTAPP_NAME' present"
557
558start_lttng_sessiond
559
560tests=(
561 test_log4j_multi_session_disable_wildcard
562 test_log4j_multi_session_disable_wildcard_begin
563 test_log4j_multi_session_disable_wildcard_middle
564 test_log4j_multi_session_disable_wildcard_end
565 test_log4j_multi_session_disable
566 test_log4j_disable
567 test_log4j_disable_enable
568 test_log4j_disable_all
569 test_log4j_filtering
570 test_log4j_multi_session_loglevel
571 test_log4j_destroy_session
572 test_log4j_loglevel
573 test_log4j_loglevel_multiple
574 test_log4j_before_start
575 test_log4j_after_start
576 test_log4j_multi_session
577 test_log4j_filter_loglevel
578)
579
580for fct_test in "${tests[@]}";
581do
582 TRACE_PATH=$(mktemp --tmpdir -d tmp.test_java_log4j_trace_path.XXXXXX)
583
584 ${fct_test}
585
586 rm -rf "$TRACE_PATH"
587done
588
589stop_lttng_sessiond
This page took 0.116308 seconds and 4 git commands to generate.