Fix: lttng-snapshot: use after free of max size argument
[lttng-tools.git] / tests / regression / ust / java-jul / test_java_jul
index 48c8b7401c7e5721d26223a6d10bed72ebf2d4d1..90c1758e1131fabbf68ad5cba1e87bd1f353d207 100755 (executable)
@@ -1,19 +1,8 @@
 #!/bin/bash
 #
-# Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+# Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
 #
-# This program is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License, version 2 only, as published by
-# the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# SPDX-License-Identifier: GPL-2.0-only
 
 TEST_DESC="Java JUL support"
 
@@ -27,9 +16,9 @@ TESTAPP_PATH="$CURDIR/$TESTAPP_NAME"
 SESSION_NAME="jul"
 EVENT_NAME="JTestLTTng"
 EVENT_NAME2="JTestLTTng2"
-JAVA_CP="$CURDIR:/usr/local/share/java/liblttng-ust-agent.jar:/usr/share/java/liblttng-ust-agent.jar"
+JAVA_CP="$CURDIR:$CLASSPATH"
 
-NUM_TESTS=155
+NUM_TESTS=195
 
 source $TESTDIR/utils/utils.sh
 
@@ -39,7 +28,7 @@ function run_app
        local fire_second_tp=$2
 
        #FIXME: app should have synchro.
-       java -cp $JAVA_CP -Djava.library.path="/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT $finest_tp $fire_second_tp >/dev/null 2>&1
+       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
 }
 
 function run_app_background
@@ -90,8 +79,8 @@ function enable_jul_filter_loglevel_only()
 
 function test_jul_before_start ()
 {
-       local file_sync_after_first=$(mktemp -u)
-       local file_sync_before_last=$(mktemp -u)
+       local file_sync_after_first=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX")
+       local file_sync_before_last=$(mktemp --tmpdir -u "tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX")
 
        diag "Test JUL application BEFORE tracing starts"
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
@@ -338,6 +327,119 @@ function test_jul_multi_session_disable_wildcard()
        fi
 }
 
+function test_jul_multi_session_disable_wildcard_begin()
+{
+       ev_name='*LTTng'
+       diag "Test JUL with multiple session with disabled wildcard (at the beginning) event"
+
+       create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
+       enable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
+
+       create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
+       enable_jul_lttng_event $SESSION_NAME-2 "$ev_name"
+
+       disable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
+
+       start_lttng_tracing_ok $SESSION_NAME-1
+       start_lttng_tracing_ok $SESSION_NAME-2
+
+       run_app 0 1
+
+       stop_lttng_tracing_ok $SESSION_NAME-1
+       stop_lttng_tracing_ok $SESSION_NAME-2
+       destroy_lttng_session_ok $SESSION_NAME-1
+       destroy_lttng_session_ok $SESSION_NAME-2
+
+       # Validate test. Expecting NO event of the first TP.
+       trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1
+       if [ $? -ne 0 ]; then
+               return $?
+       fi
+
+       # Validate test. Expecting all events of the first TP.
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2
+       if [ $? -ne 0 ]; then
+               return $?
+       fi
+}
+
+function test_jul_multi_session_disable_wildcard_middle()
+{
+       ev_name='J*LTTng'
+       diag "Test JUL with multiple session with disabled wildcard (at the middle) event"
+
+       create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
+       enable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
+
+       create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
+       enable_jul_lttng_event $SESSION_NAME-2 "$ev_name"
+
+       disable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
+
+       start_lttng_tracing_ok $SESSION_NAME-1
+       start_lttng_tracing_ok $SESSION_NAME-2
+
+       run_app 0 1
+
+       stop_lttng_tracing_ok $SESSION_NAME-1
+       stop_lttng_tracing_ok $SESSION_NAME-2
+       destroy_lttng_session_ok $SESSION_NAME-1
+       destroy_lttng_session_ok $SESSION_NAME-2
+
+       # Validate test. Expecting NO event of the first TP.
+       trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1
+       if [ $? -ne 0 ]; then
+               return $?
+       fi
+
+       # Validate test. Expecting all events of the first TP.
+       trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2
+       if [ $? -ne 0 ]; then
+               return $?
+       fi
+}
+
+function test_jul_multi_session_disable_wildcard_end()
+{
+       ev_name='JTestLTT*'
+       diag "Test JUL with multiple session with disabled wildcard (at the end) event"
+
+       create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1
+       enable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
+
+       create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2
+       enable_jul_lttng_event $SESSION_NAME-2 "$ev_name"
+
+       disable_jul_lttng_event $SESSION_NAME-1 "$ev_name"
+
+       start_lttng_tracing_ok $SESSION_NAME-1
+       start_lttng_tracing_ok $SESSION_NAME-2
+
+       run_app 0 1
+
+       stop_lttng_tracing_ok $SESSION_NAME-1
+       stop_lttng_tracing_ok $SESSION_NAME-2
+       destroy_lttng_session_ok $SESSION_NAME-1
+       destroy_lttng_session_ok $SESSION_NAME-2
+
+       # Validate test. Expecting NO event of the first TP.
+       trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1
+       if [ $? -ne 0 ]; then
+               return $?
+       fi
+
+       # Validate test. Expecting all events of the first TP.
+       trace_matches $EVENT_NAME $(( $NR_ITER + 1 )) $TRACE_PATH/$SESSION_NAME-2
+       if [ $? -ne 0 ]; then
+               return $?
+       fi
+
+       trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2
+       if [ $? -ne 0 ]; then
+               return $?
+       fi
+}
+
 function test_jul_disable_all()
 {
        diag "Test JUL with multiple session with disabled all event"
@@ -347,7 +449,7 @@ function test_jul_disable_all()
        enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
        enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
 
-       disable_jul_lttng_event $SESSION_NAME '*'
+       disable_jul_lttng_event $SESSION_NAME -a
 
        start_lttng_tracing_ok $SESSION_NAME
 
@@ -560,6 +662,8 @@ plan_tests $NUM_TESTS
 
 print_test_banner "$TEST_DESC"
 
+bail_out_if_no_babeltrace
+
 if [ ! -f "$TESTAPP_PATH.class" ]; then
        withapp=0
 else
@@ -571,6 +675,9 @@ skip $withapp "JUL support is needed. Skipping all tests." $NUM_TESTS ||
        start_lttng_sessiond
 
        tests=(
+               test_jul_multi_session_disable_wildcard_begin
+               test_jul_multi_session_disable_wildcard_middle
+               test_jul_multi_session_disable_wildcard_end
                test_jul_multi_session_disable_wildcard
                test_jul_multi_session_disable
                test_jul_disable
@@ -589,7 +696,7 @@ skip $withapp "JUL support is needed. Skipping all tests." $NUM_TESTS ||
 
        for fct_test in ${tests[@]};
        do
-               TRACE_PATH=$(mktemp -d)
+               TRACE_PATH=$(mktemp --tmpdir -d tmp.test_java_jul_trace_path.XXXXXX)
 
                ${fct_test}
                if [ $? -ne 0 ]; then
This page took 0.035261 seconds and 4 git commands to generate.