Tests: Java agent: update after Java agent refactoring
[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
958d2529 32NUM_TESTS=155
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
341function test_jul_disable_all()
342{
343 diag "Test JUL with multiple session with disabled all event"
344
bf6ae429 345 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
958d2529
DG
346 enable_jul_lttng_event $SESSION_NAME '*'
347 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
348 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
349
350 disable_jul_lttng_event $SESSION_NAME '*'
351
e563bbdb 352 start_lttng_tracing_ok $SESSION_NAME
958d2529
DG
353
354 run_app 0 1
355
96340a01 356 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 357 destroy_lttng_session_ok $SESSION_NAME
958d2529
DG
358
359 # Validate test. Expecting NO event of the first TP and second TP.
360 trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME
361 trace_match_only $EVENT_NAME2 0 $TRACE_PATH/$SESSION_NAME
362 if [ $? -ne 0 ]; then
363 return $?
364 fi
365}
366
9b21e6d5
DG
367function test_jul_multi_session()
368{
369 diag "Test JUL with multiple session"
370
bf6ae429 371 create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
9b21e6d5 372 enable_jul_lttng_event $SESSION_NAME-1 $EVENT_NAME
e563bbdb 373 start_lttng_tracing_ok $SESSION_NAME-1
9b21e6d5 374
bf6ae429 375 create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
9b21e6d5 376 enable_jul_lttng_event $SESSION_NAME-2 $EVENT_NAME2
e563bbdb 377 start_lttng_tracing_ok $SESSION_NAME-2
9b21e6d5
DG
378
379 # Run 5 times with a 1 second delay and fire second TP.
380 run_app 0 1
9b21e6d5 381
96340a01
JR
382 stop_lttng_tracing_ok $SESSION_NAME-1
383 stop_lttng_tracing_ok $SESSION_NAME-2
67b4c664
JR
384 destroy_lttng_session_ok $SESSION_NAME-1
385 destroy_lttng_session_ok $SESSION_NAME-2
9b21e6d5
DG
386
387 # Validate test. Expecting all events of first TP
d53addeb 388 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1
9b21e6d5
DG
389 if [ $? -ne 0 ]; then
390 return $?
391 fi
392
393 # Validate test. Expecting one event of the second TP.
d53addeb 394 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
9b21e6d5
DG
395 if [ $? -ne 0 ]; then
396 return $?
397 fi
398}
399
3e1c9ff7
DG
400function test_jul_destroy_session()
401{
402 diag "Test JUL two session with destroy"
403
bf6ae429 404 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/first-sess
3e1c9ff7 405 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 406 start_lttng_tracing_ok $SESSION_NAME
3e1c9ff7
DG
407
408 # Run 5 times with a 1 second delay
b06d6a6f 409 run_app_background 0 1
3e1c9ff7 410
0fc2834c
MD
411 # Wait for the applications started in background
412 wait
3e1c9ff7 413
96340a01 414 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 415 destroy_lttng_session_ok $SESSION_NAME
3e1c9ff7
DG
416
417 # Validate test. Expecting at least one event num 1
418 validate_trace $EVENT_NAME $TRACE_PATH/first-sess
419 if [ $? -ne 0 ]; then
420 return $?
421 fi
422
bf6ae429 423 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/second-sess
3e1c9ff7 424 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
e563bbdb 425 start_lttng_tracing_ok $SESSION_NAME
3e1c9ff7 426
0fc2834c
MD
427 # Run 5 times with a 1 second delay
428 run_app_background 0 1
429
b06d6a6f 430 # Wait for the applications started in background
0fc2834c 431 wait
3e1c9ff7 432
96340a01 433 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 434 destroy_lttng_session_ok $SESSION_NAME
3e1c9ff7
DG
435
436 # Validate test. Expecting only one event num 2
d53addeb 437 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/second-sess
3e1c9ff7
DG
438 if [ $? -ne 0 ]; then
439 return $?
440 fi
441}
442
34c40351
DG
443function test_jul_filtering()
444{
445 diag "Test JUL filtering"
446
bf6ae429 447 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
34c40351
DG
448 # Enable all event with a filter.
449 enable_jul_filter $SESSION_NAME '*' 'msg == "JUL second logger fired"'
e563bbdb 450 start_lttng_tracing_ok $SESSION_NAME
34c40351
DG
451
452 # Run 5 times with a 1 second delay and fire second TP.
453 run_app 0 1
34c40351 454
96340a01 455 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 456 destroy_lttng_session_ok $SESSION_NAME
34c40351
DG
457
458 # Validate test. Expecting one event of the second TP only.
d53addeb 459 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
34c40351
DG
460 if [ $? -ne 0 ]; then
461 return $?
462 fi
463
bf6ae429 464 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
34c40351
DG
465 # Enable first Logger but filter msg payload for the INFO one while
466 # triggering the finest and second TP.
467 enable_jul_filter $SESSION_NAME $EVENT_NAME 'msg == "JUL tp fired!"'
e563bbdb 468 start_lttng_tracing_ok $SESSION_NAME
34c40351
DG
469
470 # Run 5 times with a 1 second delay, fire finest and second TP.
471 run_app 1 1
34c40351 472
96340a01 473 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 474 destroy_lttng_session_ok $SESSION_NAME
34c40351
DG
475
476 # Validate test. Expecting NR_ITER event of the main INFO tp.
d53addeb 477 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME
34c40351
DG
478 if [ $? -ne 0 ]; then
479 return $?
480 fi
481}
482
1d842d5a
DG
483function test_jul_disable()
484{
485 diag "Test JUL disable event"
486
bf6ae429 487 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
1d842d5a
DG
488 # Enable all event with a filter.
489 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
490 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
491 disable_jul_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 492 start_lttng_tracing_ok $SESSION_NAME
1d842d5a
DG
493
494 # Run 5 times with a 1 second delay and fire second TP.
495 run_app 0 1
1d842d5a 496
96340a01 497 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 498 destroy_lttng_session_ok $SESSION_NAME
1d842d5a
DG
499
500 # Validate test. Expecting one event of the second TP only.
d53addeb 501 trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
1d842d5a
DG
502 if [ $? -ne 0 ]; then
503 return $?
504 fi
505}
506
507function test_jul_disable_enable()
508{
509 diag "Test JUL disable event followed by an enable"
510
bf6ae429 511 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
1d842d5a
DG
512 # Enable all event with a filter.
513 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
514 disable_jul_lttng_event $SESSION_NAME $EVENT_NAME
515 enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
e563bbdb 516 start_lttng_tracing_ok $SESSION_NAME
1d842d5a
DG
517
518 # Run 5 times with a 1 second delay and fire second TP.
519 run_app 0 1
1d842d5a 520
96340a01 521 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 522 destroy_lttng_session_ok $SESSION_NAME
1d842d5a
DG
523
524 # Validate test. Expecting NR_ITER event of the main INFO tp.
d53addeb 525 trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME
1d842d5a
DG
526 if [ $? -ne 0 ]; then
527 return $?
528 fi
529}
530
c4fd489f
JG
531function test_jul_filter_loglevel()
532{
533 local BOGUS_EVENT_NAME="not_a_real_event"
534 local FILTER="int_loglevel > 700 || int_loglevel < 700"
535 local ALL_EVENTS="."
536
537 diag "Test JUL a filter with a loglevel"
538
bf6ae429 539 create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME
c4fd489f
JG
540 # Enable an event with a filter and the loglevel-only option.
541 enable_jul_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" JUL_CONFIG
542 disable_jul_lttng_event $SESSION_NAME $BOGUS_EVENT_NAME
543 enable_jul_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" JUL_CONFIG
e563bbdb 544 start_lttng_tracing_ok $SESSION_NAME
c4fd489f
JG
545
546 # Run 5 times with a 1 second delay and fire second TP.
547 run_app 0 1
548
96340a01 549 stop_lttng_tracing_ok $SESSION_NAME
67b4c664 550 destroy_lttng_session_ok $SESSION_NAME
c4fd489f
JG
551
552 # Validate test. Expecting no events.
553 trace_match_only $ALL_EVENTS 0 $TRACE_PATH/$SESSION_NAME
554 if [ $? -ne 0 ]; then
555 return $?
556 fi
557}
558
37175ce4
DG
559plan_tests $NUM_TESTS
560
561print_test_banner "$TEST_DESC"
562
563if [ ! -f "$TESTAPP_PATH.class" ]; then
564 withapp=0
565else
566 withapp=1
567fi
568
569skip $withapp "JUL support is needed. Skipping all tests." $NUM_TESTS ||
570{
571 start_lttng_sessiond
572
573 tests=(
958d2529 574 test_jul_multi_session_disable_wildcard
1d842d5a
DG
575 test_jul_multi_session_disable
576 test_jul_disable
577 test_jul_disable_enable
958d2529 578 test_jul_disable_all
34c40351 579 test_jul_filtering
3e1c9ff7
DG
580 test_jul_multi_session_loglevel
581 test_jul_destroy_session
b2064f54 582 test_jul_loglevel
88f54ca9 583 test_jul_loglevel_multiple
37175ce4
DG
584 test_jul_before_start
585 test_jul_after_start
9b21e6d5 586 test_jul_multi_session
c4fd489f 587 test_jul_filter_loglevel
37175ce4
DG
588 )
589
590 for fct_test in ${tests[@]};
591 do
3e1c9ff7
DG
592 TRACE_PATH=$(mktemp -d)
593
37175ce4 594 ${fct_test}
b2064f54
DG
595 if [ $? -ne 0 ]; then
596 break;
37175ce4 597 fi
b2064f54 598 rm -rf $TRACE_PATH
37175ce4
DG
599 done
600
601 stop_lttng_sessiond
602}
This page took 0.086931 seconds and 4 git commands to generate.