From: David Goulet Date: Mon, 15 Sep 2014 19:22:12 +0000 (-0400) Subject: Test: Add the new log4j agent X-Git-Tag: v2.6.0-rc1~48 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=504d4ace8d2c38787fe40b7e74cbb932cb7f3d89;p=lttng-tools.git Test: Add the new log4j agent This adds the log4j java agent test. It also moves the JUL test and build system to use the new UST java agent jar. Signed-off-by: David Goulet --- diff --git a/.gitignore b/.gitignore index cbcff9ea2..a5d110b8a 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ tags /config/ !config/epoll.m4 !config/config_feature.m4 +!/config/ax_* /src/bin/lttng-sessiond/lttng-sessiond /src/bin/lttng/lttng diff --git a/config/ax_check_class.m4 b/config/ax_check_class.m4 new file mode 100644 index 000000000..098aa7729 --- /dev/null +++ b/config/ax_check_class.m4 @@ -0,0 +1,144 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_class.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_CLASS +# +# DESCRIPTION +# +# AX_CHECK_CLASS tests the existence of a given Java class, either in a +# jar or in a '.class' file. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AU_ALIAS([AC_CHECK_CLASS], [AX_CHECK_CLASS]) +AC_DEFUN([AX_CHECK_CLASS],[ +AC_REQUIRE([AX_PROG_JAVA]) +ac_var_name=`echo $1 | sed 's/\./_/g'` +dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is +dnl dynamic I need an extra level of extraction +AC_MSG_CHECKING([for $1 class]) +AC_CACHE_VAL(ax_cv_class_$ac_var_name, [ +if test x$ac_cv_prog_uudecode_base64 = xyes; then +dnl /** +dnl * Test.java: used to test dynamicaly if a class exists. +dnl */ +dnl public class Test +dnl { +dnl +dnl public static void +dnl main( String[] argv ) +dnl { +dnl Class lib; +dnl if (argv.length < 1) +dnl { +dnl System.err.println ("Missing argument"); +dnl System.exit (77); +dnl } +dnl try +dnl { +dnl lib = Class.forName (argv[0]); +dnl } +dnl catch (ClassNotFoundException e) +dnl { +dnl System.exit (1); +dnl } +dnl lib = null; +dnl System.exit (0); +dnl } +dnl +dnl } +cat << \EOF > Test.uue +begin-base64 644 Test.class +yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE +bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 +bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ +AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt +ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV +ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp +VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM +amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi +AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B +AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA +AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN +uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK +AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA +JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA +JwAAAAIAKA== +==== +EOF + if $UUDECODE Test.uue; then + : + else + echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD + echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD + cat Test.uue >&AS_MESSAGE_LOG_FD + ac_cv_prog_uudecode_base64=no + fi + rm -f Test.uue + if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then + eval "ac_cv_class_$ac_var_name=yes" + else + eval "ac_cv_class_$ac_var_name=no" + fi + rm -f Test.class +else + AX_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"], + [eval "ac_cv_class_$ac_var_name=no"]) +fi +eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`" +eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`" +HAVE_LAST_CLASS=$ac_var_val +if test x$ac_var_val = xyes; then + ifelse([$2], , :, [$2]) +else + ifelse([$3], , :, [$3]) +fi +]) +dnl for some reason the above statment didn't fall though here? +dnl do scripts have variable scoping? +eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`" +AC_MSG_RESULT($ac_var_val) +]) diff --git a/config/ax_check_classpath.m4 b/config/ax_check_classpath.m4 new file mode 100644 index 000000000..3c9081a08 --- /dev/null +++ b/config/ax_check_classpath.m4 @@ -0,0 +1,60 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_classpath.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_CLASSPATH +# +# DESCRIPTION +# +# AX_CHECK_CLASSPATH just displays the CLASSPATH, for the edification of +# the user. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 5 + +AU_ALIAS([AC_CHECK_CLASSPATH], [AX_CHECK_CLASSPATH]) +AC_DEFUN([AX_CHECK_CLASSPATH],[ +if test "x$CLASSPATH" = x; then + echo "You have no CLASSPATH, I hope it is good" +else + echo "You have CLASSPATH $CLASSPATH, hope it is correct" +fi +]) diff --git a/config/ax_check_rqrd_class.m4 b/config/ax_check_rqrd_class.m4 new file mode 100644 index 000000000..8f14241b1 --- /dev/null +++ b/config/ax_check_rqrd_class.m4 @@ -0,0 +1,62 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_rqrd_class.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_RQRD_CLASS +# +# DESCRIPTION +# +# AX_CHECK_RQRD_CLASS tests the existence of a given Java class, either in +# a jar or in a '.class' file and fails if it doesn't exist. Its success +# or failure can depend on a proper setting of the CLASSPATH env. +# variable. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 5 + +AU_ALIAS([AC_CHECK_RQRD_CLASS], [AX_CHECK_RQRD_CLASS]) +AC_DEFUN([AX_CHECK_RQRD_CLASS],[ +CLASS=`echo $1|sed 's/\./_/g'` +AC_CHECK_CLASS($1) +if test "$HAVE_LAST_CLASS" = "no"; then + AC_MSG_ERROR([Required class $1 missing, exiting.]) +fi +]) diff --git a/config/ax_java_options.m4 b/config/ax_java_options.m4 new file mode 100644 index 000000000..36c10d922 --- /dev/null +++ b/config/ax_java_options.m4 @@ -0,0 +1,48 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_java_options.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_JAVA_OPTIONS +# +# DESCRIPTION +# +# AX_JAVA_OPTIONS adds configure command line options used for Java m4 +# macros. This Macro is optional. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AU_ALIAS([AC_JAVA_OPTIONS], [AX_JAVA_OPTIONS]) +AC_DEFUN([AX_JAVA_OPTIONS],[ +AC_ARG_WITH(java-prefix, + [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)]) +AC_ARG_WITH(javac-flags, + [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)]) +AC_ARG_WITH(java-flags, + [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)]) +JAVAPREFIX=$with_java_prefix +JAVACFLAGS=$with_javac_flags +JAVAFLAGS=$with_java_flags +AC_SUBST(JAVAPREFIX)dnl +AC_SUBST(JAVACFLAGS)dnl +AC_SUBST(JAVAFLAGS)dnl +AC_SUBST(JAVA)dnl +AC_SUBST(JAVAC)dnl +]) diff --git a/config/ax_jni_include_dir.m4 b/config/ax_jni_include_dir.m4 new file mode 100644 index 000000000..b664d80b8 --- /dev/null +++ b/config/ax_jni_include_dir.m4 @@ -0,0 +1,126 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_JNI_INCLUDE_DIR +# +# DESCRIPTION +# +# AX_JNI_INCLUDE_DIR finds include directories needed for compiling +# programs using the JNI interface. +# +# JNI include directories are usually in the Java distribution. This is +# deduced from the value of $JAVA_HOME, $JAVAC, or the path to "javac", in +# that order. When this macro completes, a list of directories is left in +# the variable JNI_INCLUDE_DIRS. +# +# Example usage follows: +# +# AX_JNI_INCLUDE_DIR +# +# for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS +# do +# CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR" +# done +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVAC=yourcompiler before calling +# AX_JNI_INCLUDE_DIR +# +# - at the configure level, setenv JAVAC +# +# Note: This macro can work with the autoconf M4 macros for Java programs. +# This particular macro is not part of the original set of macros. +# +# LICENSE +# +# Copyright (c) 2008 Don Anderson +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 10 + +AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR]) +AC_DEFUN([AX_JNI_INCLUDE_DIR],[ + +JNI_INCLUDE_DIRS="" + +if test "x$JAVA_HOME" != x; then + _JTOPDIR="$JAVA_HOME" +else + if test "x$JAVAC" = x; then + JAVAC=javac + fi + AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no]) + if test "x$_ACJNI_JAVAC" = xno; then + AC_MSG_ERROR([cannot find JDK; try setting \$JAVAC or \$JAVA_HOME]) + fi + _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC") + _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'` +fi + +case "$host_os" in + darwin*) _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` + _JINC="$_JTOPDIR/Headers";; + *) _JINC="$_JTOPDIR/include";; +esac +_AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR]) +_AS_ECHO_LOG([_JINC=$_JINC]) + +# On Mac OS X 10.6.4, jni.h is a symlink: +# /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h +# -> ../../CurrentJDK/Headers/jni.h. +AC_CHECK_FILE([$_JINC/jni.h], + [JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC"], + [_JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` + AC_CHECK_FILE([$_JTOPDIR/include/jni.h], + [JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include"], + AC_MSG_ERROR([cannot find JDK header files])) + ]) + +# get the likely subdirectories for system specific java includes +case "$host_os" in +bsdi*) _JNI_INC_SUBDIRS="bsdos";; +freebsd*) _JNI_INC_SUBDIRS="freebsd";; +linux*) _JNI_INC_SUBDIRS="linux genunix";; +osf*) _JNI_INC_SUBDIRS="alpha";; +solaris*) _JNI_INC_SUBDIRS="solaris";; +mingw*) _JNI_INC_SUBDIRS="win32";; +cygwin*) _JNI_INC_SUBDIRS="win32";; +*) _JNI_INC_SUBDIRS="genunix";; +esac + +# add any subdirectories that are present +for JINCSUBDIR in $_JNI_INC_SUBDIRS +do + if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then + JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR" + fi +done +]) + +# _ACJNI_FOLLOW_SYMLINKS +# Follows symbolic links on , +# finally setting variable _ACJNI_FOLLOWED +# ---------------------------------------- +AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[ +# find the include directory relative to the javac executable +_cur="$1" +while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do + AC_MSG_CHECKING([symlink for $_cur]) + _slink=`ls -ld "$_cur" | sed 's/.* -> //'` + case "$_slink" in + /*) _cur="$_slink";; + # 'X' avoids triggering unwanted echo options. + *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; + esac + AC_MSG_RESULT([$_cur]) +done +_ACJNI_FOLLOWED="$_cur" +])# _ACJNI diff --git a/config/ax_prog_jar.m4 b/config/ax_prog_jar.m4 new file mode 100644 index 000000000..3c60fcaf2 --- /dev/null +++ b/config/ax_prog_jar.m4 @@ -0,0 +1,49 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_jar.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAR +# +# DESCRIPTION +# +# AX_PROG_JAR tests for an existing jar program. It uses the environment +# variable JAR then tests in sequence various common jar programs. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAR=yourcompiler before calling +# AX_PROG_JAR +# +# - at the configure level, setenv JAR +# +# You can use the JAR variable in your Makefile.in, with @JAR@. +# +# Note: This macro depends on the autoconf M4 macros for Java programs. It +# is VERY IMPORTANT that you download that whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# The general documentation of those macros, as well as the sample +# configure.in, is included in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Egon Willighagen +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AU_ALIAS([AC_PROG_JAR], [AX_PROG_JAR]) +AC_DEFUN([AX_PROG_JAR],[ +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar])], + [test "x$JAR" = x && AC_CHECK_PROGS([JAR], [jar], [], [$JAVAPREFIX/bin])]) +test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH]) +AC_PROVIDE([$0])dnl +]) diff --git a/config/ax_prog_java.m4 b/config/ax_prog_java.m4 new file mode 100644 index 000000000..03961db5b --- /dev/null +++ b/config/ax_prog_java.m4 @@ -0,0 +1,115 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA +# +# DESCRIPTION +# +# Here is a summary of the main macros: +# +# AX_PROG_JAVAC: finds a Java compiler. +# +# AX_PROG_JAVA: finds a Java virtual machine. +# +# AX_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!). +# +# AX_CHECK_RQRD_CLASS: finds if we have the given class and stops +# otherwise. +# +# AX_TRY_COMPILE_JAVA: attempt to compile user given source. +# +# AX_TRY_RUN_JAVA: attempt to compile and run user given source. +# +# AX_JAVA_OPTIONS: adds Java configure options. +# +# AX_PROG_JAVA tests an existing Java virtual machine. It uses the +# environment variable JAVA then tests in sequence various common Java +# virtual machines. For political reasons, it starts with the free ones. +# You *must* call [AX_PROG_JAVAC] before. +# +# If you want to force a specific VM: +# +# - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA +# +# (but after AC_INIT) +# +# - at the configure level, setenv JAVA +# +# You can use the JAVA variable in your Makefile.in, with @JAVA@. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# TODO: allow to exclude virtual machines (rationale: most Java programs +# cannot run with some VM like kaffe). +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. +# +# A Web page, with a link to the latest CVS snapshot is at +# . +# +# This is a sample configure.in Process this file with autoconf to produce +# a configure script. +# +# AC_INIT(UnTag.java) +# +# dnl Checks for programs. +# AC_CHECK_CLASSPATH +# AX_PROG_JAVAC +# AX_PROG_JAVA +# +# dnl Checks for classes +# AX_CHECK_RQRD_CLASS(org.xml.sax.Parser) +# AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver) +# +# AC_OUTPUT(Makefile) +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([AC_PROG_JAVA], [AX_PROG_JAVA]) +AC_DEFUN([AX_PROG_JAVA],[ +m4_define([m4_ax_prog_java_list], [kaffe java])dnl +AS_IF([test "x$JAVAPREFIX" = x], + [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list])], + [test x$JAVA = x && AC_CHECK_PROGS([JAVA], [m4_ax_prog_java_list], [], [$JAVAPREFIX/bin])]) +test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH]) +m4_undefine([m4_ax_prog_java_list])dnl +AX_PROG_JAVA_WORKS +AC_PROVIDE([$0])dnl +]) diff --git a/config/ax_prog_java_works.m4 b/config/ax_prog_java_works.m4 new file mode 100644 index 000000000..54e132afa --- /dev/null +++ b/config/ax_prog_java_works.m4 @@ -0,0 +1,134 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVA_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 9 + +AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS]) +AC_DEFUN([AX_PROG_JAVA_WORKS], [ +AC_PATH_PROG(UUDECODE, uudecode, [no]) +if test x$UUDECODE != xno; then +AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [ +dnl /** +dnl * Test.java: used to test if java compiler works. +dnl */ +dnl public class Test +dnl { +dnl +dnl public static void +dnl main( String[] argv ) +dnl { +dnl System.exit (0); +dnl } +dnl +dnl } +cat << \EOF > Test.uue +begin-base64 644 Test.class +yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE +bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 +bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s +YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG +aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB +AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB +AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ= +==== +EOF +if $UUDECODE Test.uue; then + ac_cv_prog_uudecode_base64=yes +else + echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD + echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD + cat Test.uue >&AS_MESSAGE_LOG_FD + ac_cv_prog_uudecode_base64=no +fi +rm -f Test.uue]) +fi +if test x$ac_cv_prog_uudecode_base64 != xyes; then + rm -f Test.class + AC_MSG_WARN([I have to compile Test.class from scratch]) + if test x$ac_cv_prog_javac_works = xno; then + AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) + fi + if test x$ac_cv_prog_javac_works = x; then + AX_PROG_JAVAC + fi +fi +AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +TEST=Test +changequote(, )dnl +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +public static void main (String args[]) { + System.exit (0); +} } +EOF +changequote([, ])dnl +if test x$ac_cv_prog_uudecode_base64 != xyes; then + if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then + : + else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD + AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) + fi +fi +if AC_TRY_COMMAND($JAVA -classpath . $JAVAFLAGS $TEST) >/dev/null 2>&1; then + ac_cv_prog_java_works=yes +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD + AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) +fi +rm -fr $JAVA_TEST $CLASS_TEST Test.uue +]) +AC_PROVIDE([$0])dnl +] +) diff --git a/config/ax_prog_javac.m4 b/config/ax_prog_javac.m4 new file mode 100644 index 000000000..d061243cd --- /dev/null +++ b/config/ax_prog_javac.m4 @@ -0,0 +1,79 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javac.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAC +# +# DESCRIPTION +# +# AX_PROG_JAVAC tests an existing Java compiler. It uses the environment +# variable JAVAC then tests in sequence various common Java compilers. For +# political reasons, it starts with the free ones. +# +# If you want to force a specific compiler: +# +# - at the configure.in level, set JAVAC=yourcompiler before calling +# AX_PROG_JAVAC +# +# - at the configure level, setenv JAVAC +# +# You can use the JAVAC variable in your Makefile.in, with @JAVAC@. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# TODO: allow to exclude compilers (rationale: most Java programs cannot +# compile with some compilers like guavac). +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 7 + +AU_ALIAS([AC_PROG_JAVAC], [AX_PROG_JAVAC]) +AC_DEFUN([AX_PROG_JAVAC],[ +m4_define([m4_ax_prog_javac_list],["gcj -C" guavac jikes javac])dnl +AS_IF([test "x$JAVAPREFIX" = x], + [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list])], + [test "x$JAVAC" = x && AC_CHECK_PROGS([JAVAC], [m4_ax_prog_javac_list], [], [$JAVAPREFIX/bin])]) +m4_undefine([m4_ax_prog_javac_list])dnl +test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) +AX_PROG_JAVAC_WORKS +AC_PROVIDE([$0])dnl +]) diff --git a/config/ax_prog_javac_works.m4 b/config/ax_prog_javac_works.m4 new file mode 100644 index 000000000..7dfa1e37d --- /dev/null +++ b/config/ax_prog_javac_works.m4 @@ -0,0 +1,72 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAC_WORKS +# +# DESCRIPTION +# +# Internal use ONLY. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Stephane Bortzmeyer +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 6 + +AU_ALIAS([AC_PROG_JAVAC_WORKS], [AX_PROG_JAVAC_WORKS]) +AC_DEFUN([AX_PROG_JAVAC_WORKS],[ +AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then + ac_cv_prog_javac_works=yes +else + AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat $JAVA_TEST >&AS_MESSAGE_LOG_FD +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +AC_PROVIDE([$0])dnl +]) diff --git a/config/ax_prog_javah.m4 b/config/ax_prog_javah.m4 new file mode 100644 index 000000000..2809f29cf --- /dev/null +++ b/config/ax_prog_javah.m4 @@ -0,0 +1,47 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_javah.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_JAVAH +# +# DESCRIPTION +# +# AX_PROG_JAVAH tests the availability of the javah header generator and +# looks for the jni.h header file. If available, JAVAH is set to the full +# path of javah and CPPFLAGS is updated accordingly. +# +# LICENSE +# +# Copyright (c) 2008 Luc Maisonobe +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AU_ALIAS([AC_PROG_JAVAH], [AX_PROG_JAVAH]) +AC_DEFUN([AX_PROG_JAVAH],[ +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_PATH_PROG(JAVAH,javah) +AS_IF([test -n "$ac_cv_path_JAVAH"], + [ + AC_TRY_CPP([#include ],,[ + ac_save_CPPFLAGS="$CPPFLAGS" + ax_prog_javah_bin_dir=`AS_DIRNAME([$ac_cv_path_JAVAH])` + ac_dir="`AS_DIRNAME([$ax_prog_javah_bin])`/include" + AS_CASE([$build_os], + [cygwin*], + [ac_machdep=win32], + [ac_machdep=`AS_ECHO($build_os) | sed 's,[[-0-9]].*,,'`]) + CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep" + AC_TRY_CPP([#include ], + ac_save_CPPFLAGS="$CPPFLAGS", + AC_MSG_WARN([unable to include ])) + CPPFLAGS="$ac_save_CPPFLAGS"]) + ]) +]) diff --git a/config/ax_try_compile_java.m4 b/config/ax_try_compile_java.m4 new file mode 100644 index 000000000..a8ed6b2a3 --- /dev/null +++ b/config/ax_try_compile_java.m4 @@ -0,0 +1,55 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_try_compile_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_TRY_COMPILE_JAVA +# +# DESCRIPTION +# +# AX_TRY_COMPILE_JAVA attempt to compile user given source. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_TRY_COMPILE_JAVA], [AX_TRY_COMPILE_JAVA]) +AC_DEFUN([AX_TRY_COMPILE_JAVA],[ +AC_REQUIRE([AX_PROG_JAVAC])dnl +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +ifelse([$1], , , [import $1;]) +public class Test { +[$2] +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class +then +dnl Don't remove the temporary files here, so they can be examined. + ifelse([$3], , :, [$3]) +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat Test.java >&AS_MESSAGE_LOG_FD +ifelse([$4], , , [ rm -fr Test.java Test.class + $4 +])dnl +fi +rm -fr Test.java Test.class]) diff --git a/config/ax_try_run_java.m4 b/config/ax_try_run_java.m4 new file mode 100644 index 000000000..c680f03f2 --- /dev/null +++ b/config/ax_try_run_java.m4 @@ -0,0 +1,56 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_try_run_java.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_TRY_RUN_JAVA +# +# DESCRIPTION +# +# AX_TRY_RUN_JAVA attempt to compile and run user given source. +# +# *Warning*: its success or failure can depend on a proper setting of the +# CLASSPATH env. variable. +# +# Note: This is part of the set of autoconf M4 macros for Java programs. +# It is VERY IMPORTANT that you download the whole set, some macros depend +# on other. Unfortunately, the autoconf archive does not support the +# concept of set of macros, so I had to break it for submission. The +# general documentation, as well as the sample configure.in, is included +# in the AX_PROG_JAVA macro. +# +# LICENSE +# +# Copyright (c) 2008 Devin Weaver +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AU_ALIAS([AC_TRY_RUN_JAVA], [AX_TRY_RUN_JAVA]) +AC_DEFUN([AX_TRY_RUN_JAVA],[ +AC_REQUIRE([AX_PROG_JAVAC])dnl +AC_REQUIRE([AX_PROG_JAVA])dnl +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +ifelse([$1], , , [include $1;]) +public class Test { +[$2] +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null +then +dnl Don't remove the temporary files here, so they can be examined. + ifelse([$3], , :, [$3]) +else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat Test.java >&AS_MESSAGE_LOG_FD +ifelse([$4], , , [ rm -fr Test.java Test.class + $4 +])dnl +fi +rm -fr Test.java Test.class]) diff --git a/configure.ac b/configure.ac index 3ec407623..7b9a2fb4f 100644 --- a/configure.ac +++ b/configure.ac @@ -343,7 +343,7 @@ AX_CONFIG_FEATURE( AM_CONDITIONAL([COMPAT_EPOLL], [ test "$enable_epoll" = "yes" ]) # Set compile flags to java include files if given. This is only used to -# compile JUL tests. +# compile java agent tests. AC_ARG_WITH([java-jdk], [AS_HELP_STRING([--with-java-jdk=DIR],[use the Java JDK in DIR. Ex : $JAVA_HOME.])], [JAVA_JDK=$withval], @@ -364,20 +364,44 @@ AS_IF([test $JAVA_JDK],[ ) ]) -# Check for the UST JUL jar file in the system. Hardcoded path is added here +# Check for the UST agent jar file in the system. Hardcoded path is added here # since we have *no* idea where this could be installed. Note that this is only -# used for JUL testing. -AC_MSG_CHECKING(Java JUL UST jar file) -java_jul_jar_path="/usr/local/lib/lttng/java/liblttng-ust-jul.jar" -if test -f $java_jul_jar_path; then - build_java_jul=yes +# used for agent testing. +AC_MSG_CHECKING(Java UST agent jar file) +java_agent_jar_path="${prefix}/share/java/liblttng-ust-agent.jar" +if test -f $java_agent_jar_path; then + build_java_agent=yes AC_MSG_RESULT(found) else - build_java_jul=no + build_java_agent=no AC_MSG_RESULT(not found) fi -AM_CONDITIONAL([BUILD_JAVA_JUL], [test "x$build_java_jul" = "xyes"]) -AC_SUBST([java_jul_jar_path]) +AM_CONDITIONAL([BUILD_JAVA_AGENT], [test "x$build_java_agent" = "xyes"]) +AC_SUBST([java_agent_jar_path]) + +# Check for log4j support on the system to know if we can build or not the +# log4j tests. +if test "x$build_java_agent" = "xyes"; then + AC_MSG_CHECKING(Java agent support for log4j) + AX_JAVA_OPTIONS + AX_PROG_JAR + AX_PROG_JAVA + AX_PROG_JAVAC + + # By default, use a commonly used classpath on the system to ease things up + # for the Java testing in this directory. + LOG4J_CLASSPATH="$java_agent_jar_path:$CLASSPATH:.:/usr/share/java/*" + JAVAFLAGS="-cp $LOG4J_CLASSPATH" + JAVACFLAGS="$JAVAFLAGS" + AX_CHECK_CLASS(org.apache.log4j.Logger) + + if test "x$ac_cv_class_org_apache_log4j_Logger" = "xno"; then + build_java_log4j_agent=no + else + build_java_log4j_agent=yes + fi +fi +AM_CONDITIONAL([BUILD_JAVA_LOG4J_AGENT], [test "x$build_java_log4j_agent" = "xyes"]) AC_SYS_LARGEFILE AC_PROG_CC @@ -472,6 +496,7 @@ AC_CONFIG_FILES([ tests/regression/ust/fork/Makefile tests/regression/ust/libc-wrapper/Makefile tests/regression/ust/java-jul/Makefile + tests/regression/ust/java-log4j/Makefile tests/stress/Makefile tests/unit/Makefile tests/unit/ini_config/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index 638c82f0e..af478abda 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -20,6 +20,7 @@ regression/ust/multi-session/test_multi_session regression/ust/nprocesses/test_nprocesses regression/ust/overlap/test_overlap regression/ust/java-jul/test_java_jul +regression/ust/java-log4j/test_java_log4j regression/ust/test_event_basic regression/ust/test_event_tracef regression/ust/test_event_wildcard diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index c7583a078..273994a77 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,7 +1,7 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ overlap buffers-pid linking daemon exit-fast fork libc-wrapper \ - periodical-metadata-flush java-jul + periodical-metadata-flush java-jul java-log4j EXTRA_DIST = test_event_basic test_event_wildcard test_event_tracef test_event_perf diff --git a/tests/regression/ust/java-jul/JTestLTTng.java b/tests/regression/ust/java-jul/JTestLTTng.java index 24f4e7e1f..9431551cd 100644 --- a/tests/regression/ust/java-jul/JTestLTTng.java +++ b/tests/regression/ust/java-jul/JTestLTTng.java @@ -19,7 +19,7 @@ import java.lang.Integer; import java.util.logging.Logger; import java.util.logging.Level; -import org.lttng.ust.jul.LTTngAgent; +import org.lttng.ust.agent.LTTngAgent; public class JTestLTTng { diff --git a/tests/regression/ust/java-jul/Makefile.am b/tests/regression/ust/java-jul/Makefile.am index 302d2efda..4446c524f 100644 --- a/tests/regression/ust/java-jul/Makefile.am +++ b/tests/regression/ust/java-jul/Makefile.am @@ -1,4 +1,4 @@ -if BUILD_JAVA_JUL +if BUILD_JAVA_AGENT noinst_SCRIPTS = test_java_jul JTestLTTng.java EXTRA_DIST = test_java_jul JTestLTTng.java @@ -9,12 +9,12 @@ else JCC=javac endif -JUL_JAR_FILE=$(java_jul_jar_path) +AGENT_JAR_FILE=$(java_agent_jar_path) all-local: JTestLTTng.class %.class: %.java - $(JCC) -d "$(builddir)" -cp "$(JUL_JAR_FILE):." $< + $(JCC) -d "$(builddir)" -cp "$(AGENT_JAR_FILE):." $< JTestLTTng.class: JTestLTTng.java @@ -33,4 +33,4 @@ clean-local: done; \ fi -endif # BUILD_JAVA_JUL +endif # BUILD_JAVA_AGENT diff --git a/tests/regression/ust/java-jul/test_java_jul b/tests/regression/ust/java-jul/test_java_jul index b092e412f..bcde273be 100755 --- a/tests/regression/ust/java-jul/test_java_jul +++ b/tests/regression/ust/java-jul/test_java_jul @@ -27,7 +27,7 @@ TESTAPP_PATH="$CURDIR/$TESTAPP_NAME" SESSION_NAME="jul" EVENT_NAME="JTestLTTng" EVENT_NAME2="JTestLTTng2" -JAVA_CP="$CURDIR:/usr/local/lib/lttng/java/liblttng-ust-jul.jar:/usr/lib/lttng/java/liblttng-ust-jul.jar" +JAVA_CP="$CURDIR:/usr/local/share/java/liblttng-ust-agent.jar:/usr/share/java/liblttng-ust-agent.jar" NUM_TESTS=155 diff --git a/tests/regression/ust/java-log4j/JTestLTTng.java b/tests/regression/ust/java-log4j/JTestLTTng.java new file mode 100644 index 000000000..0019cb825 --- /dev/null +++ b/tests/regression/ust/java-log4j/JTestLTTng.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2014 - David Goulet + * Christian Babeux + * + * 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. + */ + +import java.io.IOException; +import java.lang.Integer; + +import org.apache.log4j.Logger; +import org.apache.log4j.BasicConfigurator; + +import org.lttng.ust.agent.LTTngAgent; + +public class JTestLTTng +{ + private static LTTngAgent lttngAgent; + + public static void main(String args[]) throws Exception + { + Logger lttng = Logger.getLogger("log4j-event"); + Logger lttng2 = Logger.getLogger("log4j-event-2"); + int nrIter = Integer.parseInt(args[0]); + int waitTime = Integer.parseInt(args[1]); + int fire_debug_tp = 0; + int fire_second_tp = 0; + + if (args.length > 2) { + fire_debug_tp = Integer.parseInt(args[2]); + } + if (args.length > 3) { + fire_second_tp = Integer.parseInt(args[3]); + } + + BasicConfigurator.configure(); + lttngAgent = LTTngAgent.getLTTngAgent(); + + for (int iter = 0; iter < nrIter; iter++) { + lttng.info("LOG4J tp fired!"); + if (fire_debug_tp == 1) { + /* Third arg, trigger debug TP. */ + lttng.debug("LOG4J DEBUG tp fired"); + } + Thread.sleep(waitTime); + } + + if (fire_second_tp == 1) { + lttng2.info("LOG4J second logger fired"); + } + } +} diff --git a/tests/regression/ust/java-log4j/Makefile.am b/tests/regression/ust/java-log4j/Makefile.am new file mode 100644 index 000000000..7035ecf92 --- /dev/null +++ b/tests/regression/ust/java-log4j/Makefile.am @@ -0,0 +1,34 @@ +if BUILD_JAVA_LOG4J_AGENT + +noinst_SCRIPTS = test_java_log4j JTestLTTng.java +EXTRA_DIST = test_java_log4j JTestLTTng.java + +if HAVE_JAVA_JDK +JCC=$(JAVA_JDK)/bin/javac +else +JCC=javac +endif + +all-local: JTestLTTng.class + +%.class: %.java + $(JCC) -d "$(builddir)" $(JAVACFLAGS) $< + +JTestLTTng.class: JTestLTTng.java + +all-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + cp -f $(srcdir)/$$script $(builddir); \ + done; \ + fi + +clean-local: + rm -f *.class + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + rm -f $(builddir)/$$script; \ + done; \ + fi + +endif # BUILD_JAVA_LOG4J_AGENT diff --git a/tests/regression/ust/java-log4j/test_java_log4j b/tests/regression/ust/java-log4j/test_java_log4j new file mode 100755 index 000000000..b4846c323 --- /dev/null +++ b/tests/regression/ust/java-log4j/test_java_log4j @@ -0,0 +1,590 @@ +#!/bin/bash +# +# Copyright (C) - 2014 David Goulet +# +# 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. + +TEST_DESC="Java LOG4J support" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +NR_ITER=6 +NR_MSEC_WAIT=1000 +TESTAPP_NAME="JTestLTTng" +TESTAPP_BIN="$TESTAPP_NAME.java" +TESTAPP_PATH="$CURDIR/$TESTAPP_NAME" +SESSION_NAME="log4j" +EVENT_NAME="log4j-event" +EVENT_NAME2="log4j-event-2" +JAVA_CP="$CURDIR:/usr/local/share/java/liblttng-ust-agent.jar:/usr/share/java/*" +OUTPUT_DEST="/dev/null" + +NUM_TESTS=155 + +source $TESTDIR/utils/utils.sh + +function run_app +{ + local debug_tp=$1 + local fire_second_tp=$2 + + java -cp $JAVA_CP -Djava.library.path="/usr/local/lib:/usr/lib" $TESTAPP_NAME $NR_ITER $NR_MSEC_WAIT $debug_tp $fire_second_tp >/dev/null 2>&1 +} + +function run_app_background +{ + run_app $@ & +} + +function enable_log4j_loglevel_only() +{ + sess_name=$1 + event_name="$2" + loglevel=$3 + channel_name=$4 + + if [ -z $channel_name ]; then + # default channel if none specified + chan="" + else + chan="-c $channel_name" + fi + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" $chan -s $sess_name -l >/dev/null 2>&1 + ok $? "Enable LOG4J event $event_name for session $sess_name with loglevel-only $loglevel" +} + +function enable_log4j_filter() +{ + local sess_name="$1" + local event_name="$2" + local filter="$3" + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -l --filter "$filter" >/dev/null 2>&1 + ok $? "Enable event $event_name with filter $filter for session $sess_name" +} + +function enable_log4j_filter_loglevel_only() +{ + local sess_name="$1" + local event_name="$2" + local filter="$3" + local loglevel="$4" + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" -s $sess_name -l --filter "$filter" >/dev/null 2>&1 + ok $? "Enable event $event_name with filter \"$filter\" and loglevel-only $loglevel for session $sess_name" +} + +# MUST set TESTDIR before calling those functions + +function test_log4j_before_start () +{ + diag "Test LOG4J application BEFORE tracing starts" + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + + # Run 5 times with a 1 second delay + run_app_background + + start_lttng_tracing $SESSION_NAME + + # Wait for the applications started in background + wait ${!} + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting all events. + trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_after_start () +{ + diag "Test LOG4J application AFTER tracing starts" + + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay + run_app + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting all events. + trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_loglevel () +{ + diag "Test LOG4J application with loglevel" + + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_INFO" + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay + run_app + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting all events. + trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH + if [ $? -ne 0 ]; then + return $? + fi + + diag "Test LOG4J applications with lower loglevel" + + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_FATAL" + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay + run_app + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting 0 events. + trace_match_only $EVENT_NAME 0 $TRACE_PATH + if [ $? -ne 0 ]; then + return $? + fi + + diag "Test LOG4J applications with higher loglevel" + + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_TRACE" + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay + run_app + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting all events. + trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH + return $? +} + +function test_log4j_loglevel_multiple () +{ + diag "Test LOG4J application with multiple loglevel" + + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_INFO" + enable_log4j_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "LOG4J_DEBUG" + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay and fire two TP. + run_app 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting all events times two. + trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH + if [ $? -ne 0 ]; then + return $? + fi + + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_log4j_lttng_event_loglevel $SESSION_NAME '*' "LOG4J_INFO" + enable_log4j_lttng_event_loglevel $SESSION_NAME '*' "LOG4J_DEBUG" + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay and fire two TP. + run_app 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting all events times two. + trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_multi_session_loglevel() +{ + diag "Test LOG4J with multiple session" + + create_lttng_session $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 + enable_log4j_loglevel_only $SESSION_NAME-1 '*' "LOG4J_INFO" + start_lttng_tracing $SESSION_NAME-1 + + create_lttng_session $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 + enable_log4j_loglevel_only $SESSION_NAME-2 '*' "LOG4J_DEBUG" + start_lttng_tracing $SESSION_NAME-2 + + # Run 5 times with a 1 second delay and fire second TP. + run_app 1 1 + + stop_lttng_tracing $SESSION_NAME-1 + stop_lttng_tracing $SESSION_NAME-2 + destroy_lttng_session $SESSION_NAME-1 + destroy_lttng_session $SESSION_NAME-2 + + # Expecting 6 events being the main event plus the second tp. + trace_match_only $EVENT_NAME $(($NR_ITER + 1)) $TRACE_PATH/$SESSION_NAME-1 + if [ $? -ne 0 ]; then + return $? + fi + + # Expectin 5 events being the debug TP. + trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2 + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_multi_session_disable() +{ + diag "Test LOG4J with multiple session with disabled event" + + create_lttng_session $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 + enable_log4j_lttng_event $SESSION_NAME-1 $EVENT_NAME + enable_log4j_lttng_event $SESSION_NAME-1 $EVENT_NAME2 + disable_log4j_lttng_event $SESSION_NAME-1 $EVENT_NAME + start_lttng_tracing $SESSION_NAME-1 + + create_lttng_session $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 + enable_log4j_lttng_event $SESSION_NAME-2 $EVENT_NAME2 + start_lttng_tracing $SESSION_NAME-2 + + # Run 5 times with a 1 second delay and fire second TP. + run_app 0 1 + + stop_lttng_tracing $SESSION_NAME-1 + stop_lttng_tracing $SESSION_NAME-2 + destroy_lttng_session $SESSION_NAME-1 + destroy_lttng_session $SESSION_NAME-2 + + # Validate test. Expecting one event of the second TP. + trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1 + if [ $? -ne 0 ]; then + return $? + fi + + # Validate test. Expecting one event of the second TP. + trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2 + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_multi_session_disable_wildcard() +{ + diag "Test LOG4J with multiple session with disabled wildcard event" + + create_lttng_session $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 + enable_log4j_lttng_event $SESSION_NAME-1 '*' + + create_lttng_session $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 + enable_log4j_lttng_event $SESSION_NAME-2 '*' + + disable_log4j_lttng_event $SESSION_NAME-1 '*' + + start_lttng_tracing $SESSION_NAME-1 + start_lttng_tracing $SESSION_NAME-2 + + run_app + + stop_lttng_tracing $SESSION_NAME-1 + stop_lttng_tracing $SESSION_NAME-2 + destroy_lttng_session $SESSION_NAME-1 + destroy_lttng_session $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_log4j_disable_all() +{ + diag "Test LOG4J with multiple session with disabled all event" + + create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME + enable_log4j_lttng_event $SESSION_NAME '*' + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME2 + + disable_log4j_lttng_event $SESSION_NAME '*' + + start_lttng_tracing $SESSION_NAME + + run_app 0 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting NO event of the first TP and second TP. + trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME + trace_match_only $EVENT_NAME2 0 $TRACE_PATH/$SESSION_NAME + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_multi_session() +{ + diag "Test LOG4J with multiple session" + + create_lttng_session $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1 + enable_log4j_lttng_event $SESSION_NAME-1 $EVENT_NAME + start_lttng_tracing $SESSION_NAME-1 + + create_lttng_session $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2 + enable_log4j_lttng_event $SESSION_NAME-2 $EVENT_NAME2 + start_lttng_tracing $SESSION_NAME-2 + + # Run 5 times with a 1 second delay and fire second TP. + run_app 0 1 + + stop_lttng_tracing $SESSION_NAME-1 + stop_lttng_tracing $SESSION_NAME-2 + destroy_lttng_session $SESSION_NAME-1 + destroy_lttng_session $SESSION_NAME-2 + + # Validate test. Expecting all events of first TP + trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1 + if [ $? -ne 0 ]; then + return $? + fi + + # Validate test. Expecting one event of the second TP. + trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2 + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_destroy_session() +{ + diag "Test LOG4J two session with destroy" + + create_lttng_session $SESSION_NAME $TRACE_PATH/first-sess + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay + run_app_background 0 1 + + sleep 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting at least one event num 1 + validate_trace $EVENT_NAME $TRACE_PATH/first-sess + if [ $? -ne 0 ]; then + return $? + fi + + create_lttng_session $SESSION_NAME $TRACE_PATH/second-sess + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME2 + start_lttng_tracing $SESSION_NAME + + # Wait for the applications started in background + wait ${!} + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting only one event num 2 + trace_match_only $EVENT_NAME2 1 $TRACE_PATH/second-sess + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_filtering() +{ + diag "Test LOG4J filtering" + + create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME + # Enable all event with a filter. + enable_log4j_filter $SESSION_NAME '*' 'msg == "LOG4J second logger fired"' + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay and fire second TP. + run_app 0 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting one event of the second TP only. + trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME + if [ $? -ne 0 ]; then + return $? + fi + + create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME + # Enable first Logger but filter msg payload for the INFO one while + # triggering the debug and second TP. + enable_log4j_filter $SESSION_NAME $EVENT_NAME 'msg == "LOG4J tp fired!"' + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay, fire debug and second TP. + run_app 1 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting NR_ITER event of the main INFO tp. + trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_disable() +{ + diag "Test LOG4J disable event" + + create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME + # Enable all event with a filter. + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME2 + disable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay and fire second TP. + run_app 0 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting one event of the second TP only. + trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_disable_enable() +{ + diag "Test LOG4J disable event followed by an enable" + + create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME + # Enable all event with a filter. + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + disable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + enable_log4j_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay and fire second TP. + run_app 0 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting NR_ITER event of the main INFO tp. + trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME + if [ $? -ne 0 ]; then + return $? + fi +} + +function test_log4j_filter_loglevel() +{ + local BOGUS_EVENT_NAME="not_a_real_event" + local FILTER="int_loglevel > 700 || int_loglevel < 700" + local ALL_EVENTS="." + + diag "Test LOG4J a filter with a loglevel" + + create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME + # Enable an event with a filter and the loglevel-only option. + enable_log4j_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" LOG4J_INFO + disable_log4j_lttng_event $SESSION_NAME $BOGUS_EVENT_NAME + enable_log4j_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" LOG4J_INFO + start_lttng_tracing $SESSION_NAME + + # Run 5 times with a 1 second delay and fire second TP. + run_app 0 1 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + # Validate test. Expecting no events. + trace_match_only $ALL_EVENTS 0 $TRACE_PATH/$SESSION_NAME + if [ $? -ne 0 ]; then + return $? + fi +} + +plan_tests $NUM_TESTS + +print_test_banner "$TEST_DESC" + +if [ ! -f "$TESTAPP_PATH.class" ]; then + withapp=0 +else + withapp=1 +fi + +skip $withapp "LOG4J support is needed. Skipping all tests." $NUM_TESTS || +{ + start_lttng_sessiond + + tests=( + test_log4j_multi_session_disable_wildcard + test_log4j_multi_session_disable + test_log4j_disable + test_log4j_disable_enable + test_log4j_disable_all + test_log4j_filtering + test_log4j_multi_session_loglevel + test_log4j_destroy_session + test_log4j_loglevel + test_log4j_loglevel_multiple + test_log4j_before_start + test_log4j_after_start + test_log4j_multi_session + test_log4j_filter_loglevel + ) + + for fct_test in ${tests[@]}; + do + TRACE_PATH=$(mktemp -d) + + ${fct_test} + if [ $? -ne 0 ]; then + break; + fi + rm -rf $TRACE_PATH + done + + stop_lttng_sessiond +} diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index fe552830c..117f72f1f 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -348,6 +348,41 @@ function enable_jul_lttng_event_loglevel() ok $? "Enable JUL event $event_name for session $sess_name with loglevel $loglevel" } +function enable_log4j_lttng_event() +{ + sess_name=$1 + event_name="$2" + channel_name=$3 + + if [ -z $channel_name ]; then + # default channel if none specified + chan="" + else + chan="-c $channel_name" + fi + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" $chan -s $sess_name -l >$OUTPUT_DEST + ok $? "Enable LOG4J event $event_name for session $sess_name" +} + +function enable_log4j_lttng_event_loglevel() +{ + local sess_name=$1 + local event_name="$2" + local loglevel=$3 + local channel_name=$4 + + if [ -z $channel_name ]; then + # default channel if none specified + chan="" + else + chan="-c $channel_name" + fi + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel $loglevel "$event_name" $chan -s $sess_name -l >$OUTPUT_DEST + ok $? "Enable LOG4J event $event_name for session $sess_name with loglevel $loglevel" +} + function enable_ust_lttng_event_filter() { local sess_name="$1" @@ -404,6 +439,15 @@ function disable_jul_lttng_event () ok $? "Disable JUL event $event_name for session $sess_name" } +function disable_log4j_lttng_event () +{ + local sess_name="$1" + local event_name="$2" + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -l >/dev/null 2>&1 + ok $? "Disable LOG4J event $event_name for session $sess_name" +} + function start_lttng_tracing () { local sess_name=$1