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