From 88f54ca9bfdda70f0979cf8cc06ac35ccf1724ee Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 27 Feb 2014 14:48:07 -0500 Subject: [PATCH] Tests: add JUL test for multiple loglevel Signed-off-by: David Goulet --- tests/regression/ust/java-jul/JTestLTTng.java | 6 +++ tests/regression/ust/java-jul/test_java_jul | 48 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/tests/regression/ust/java-jul/JTestLTTng.java b/tests/regression/ust/java-jul/JTestLTTng.java index 5f15e1438..b39f7e345 100644 --- a/tests/regression/ust/java-jul/JTestLTTng.java +++ b/tests/regression/ust/java-jul/JTestLTTng.java @@ -17,6 +17,7 @@ import java.lang.Integer; import java.util.logging.Logger; +import java.util.logging.Level; import org.lttng.ust.jul.LTTngAgent; @@ -31,9 +32,14 @@ public class JTestLTTng int waitTime = Integer.parseInt(args[1]); lttngAgent = LTTngAgent.getLTTngAgent(); + lttng.setLevel(Level.FINEST); for (int iter = 0; iter < nrIter; iter++) { lttng.info("JUL tp fired!"); + if (args.length == 3) { + /* Third arg, trigger finest TP. */ + lttng.finest("JUL FINEST tp fired"); + } Thread.sleep(waitTime); } diff --git a/tests/regression/ust/java-jul/test_java_jul b/tests/regression/ust/java-jul/test_java_jul index affb7eb6d..bd6a0e9b3 100755 --- a/tests/regression/ust/java-jul/test_java_jul +++ b/tests/regression/ust/java-jul/test_java_jul @@ -30,13 +30,15 @@ JAVA_CP="$CURDIR:/usr/local/lib/lttng/java/liblttng-ust-jul.jar:/usr/lib/lttng/j TRACE_PATH=$(mktemp -d) -NUM_TESTS=37 +NUM_TESTS=53 source $TESTDIR/utils/utils.sh function run_app { - java -cp $JAVA_CP -Djava.library.path="/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT >/dev/null 2>&1 & + local finest_tp=$1 + + java -cp $JAVA_CP -Djava.library.path="/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT $finest_tp >/dev/null 2>&1 & } function wait_apps @@ -156,6 +158,47 @@ function test_jul_loglevel () return $? } +function test_jul_loglevel_multiple () +{ + diag "Test JUL application with multiple loglevel" + + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_jul_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "JUL_INFO" + enable_jul_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "JUL_FINEST" + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay and fire two TP. + run_app 1 + wait_apps + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting all events times two. + trace_matches $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH + if [ $? -ne 0 ]; then + return $? + fi + + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_jul_lttng_event_loglevel $SESSION_NAME '*' "JUL_INFO" + enable_jul_lttng_event_loglevel $SESSION_NAME '*' "JUL_FINEST" + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay and fire two TP. + run_app 1 + wait_apps + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting all events times two. + trace_matches $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH + if [ $? -ne 0 ]; then + return $? + fi +} + plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" @@ -172,6 +215,7 @@ skip $withapp "JUL support is needed. Skipping all tests." $NUM_TESTS || tests=( test_jul_loglevel + test_jul_loglevel_multiple test_jul_before_start test_jul_after_start ) -- 2.34.1