<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 6, 2015 at 7:00 PM, Jonathan Rajotte <span dir="ltr"><<a href="mailto:jonathan.rajotte-julien@efficios.com" target="_blank">jonathan.rajotte-julien@efficios.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Introduce --enable-test-python{2,3}-agent and --enable-test-python-agent-all<br>
flag on configure.<br>
<br>
Tests are enabled by default via best effort. Configure looks if it can find<br>
python agent for python 2&3 and enable/skip tests.<br>
<br>
When used --enable-test-python{2,3}-agent & --enable-test-python-agent-all flags<br>
force strict checks on tests dependancies and fails at configure instead of<br>
simply disabling tests.<br>
<br>
--disable* flags can be used to force tests skipping.<br>
<br>
Also minor bug in agent test on enabling event with filtering.<br>
<br>
Signed-off-by: Jonathan Rajotte <<a href="mailto:jonathan.rajotte-julien@efficios.com">jonathan.rajotte-julien@efficios.com</a>><br>
---<br>
.gitignore | 1 +<br>
<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 121 +++-<br>
.../ust/python-logging/test_python_logging | 603 --------------------<br>
.../ust/python-logging/<a href="http://test_python_logging.in" rel="noreferrer" target="_blank">test_python_logging.in</a> | 610 +++++++++++++++++++++<br>
4 files changed, 731 insertions(+), 604 deletions(-)<br>
delete mode 100755 tests/regression/ust/python-logging/test_python_logging<br>
create mode 100755 tests/regression/ust/python-logging/<a href="http://test_python_logging.in" rel="noreferrer" target="_blank">test_python_logging.in</a><br>
<br>
diff --git a/.gitignore b/.gitignore<br>
index 5d24bec..0ce35f9 100644<br>
--- a/.gitignore<br>
+++ b/.gitignore<br>
@@ -85,6 +85,7 @@ health_check<br>
/tests/regression/ust/fork/fork<br>
/tests/regression/ust/fork/fork2<br>
/tests/regression/ust/libc-wrapper/prog<br>
+tests/regression/ust/python-logging/test_python_logging<br>
/tests/utils/testapp/gen-ust-nevents/gen-ust-nevents<br>
/tests/utils/testapp/gen-ust-tracef/gen-ust-tracef<br>
/tests/regression/tools/live/live_test<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index 324b596..386d557 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -359,7 +359,6 @@ if test "x${enable_python_binding:-yes}" = xyes; then<br>
else<br>
AC_MSG_NOTICE([You may configure with --enable-python-bindings ]dnl<br>
[if you want Python bindings.])<br>
-<br>
fi<br>
<br>
# Epoll check. If not present, the build will fallback on poll() API<br>
@@ -414,6 +413,104 @@ if test "x$test_java_agent_jul" = "xyes" || test "x$test_java_agent_log4j" = "xy<br>
fi<br>
fi<br>
<br>
+# Python agent test<br>
+UST_PYTHON_AGENT="lttngust"<br>
+<br>
+AC_ARG_ENABLE(test-python2-agent,<br>
+ AS_HELP_STRING([--enable-test-python2-agent],<br>
+ [enable tests for python2 agent. Python2 interpreter path can be overrided by env. variable PYTHON2. Default: Best effort]<br>
+ ),[:],[test_python2_agent_best_effort=yes]<br>
+)<br>
+<br>
+AC_ARG_ENABLE(test-python3-agent,<br>
+ AS_HELP_STRING([--enable-test-python3-agent],<br>
+ [enable tests for python3 agent. Python3 interpreter path can be overrided by env. variable PYTHON3. Default: Best effort]<br>
+ ),[:],[test_python3_agent_best_effort=yes]<br>
+)<br>
+<br>
+AC_ARG_ENABLE(test-python-agent-all,<br>
+ AS_HELP_STRING([--enable-test-python-agent-all],<br>
+ [enable test for all python{2/3} agent.]<br>
+ ),<br>
+)<br>
+<br>
+AS_IF([test ! -z "$enable_test_python_agent_all"], [<br>
+ unset test_python2_agent_best_effort<br>
+ unset test_python3_agent_best_effort<br>
+])<br>
+<br>
+AS_IF([test "x$enable_test_python_agent_all" = "xyes"], [<br>
+ enable_test_python2_agent=yes<br>
+ enable_test_python3_agent=yes<br>
+])<br>
+<br>
+AS_IF([test "x$enable_test_python_agent_all" = "xno"], [<br>
+ enable_test_python2_agent=no<br>
+ enable_test_python3_agent=no<br>
+])<br>
+<br>
+<br>
+AS_IF([test "x$enable_test_python2_agent" = "xyes" -o "x$test_python2_agent_best_effort" = "xyes" ], [<br>
+ AS_IF([test -z "$PYTHON2"], [<br>
+ PYTHON2=python2<br>
+ ], [<br>
+ AC_MSG_WARN([Using user-defined PYTHON2 ($PYTHON2) for lttng-ust python2 agent check])<br>
+ ])<br>
+<br>
+ AC_PATH_PROG([PYTHON2_BIN],[$PYTHON2])<br>
+ AS_IF([test -z "$PYTHON2_BIN"], [<br>
+ AS_IF([test -z "$test_python2_agent_best_effort"],[<br>
+ AC_MSG_ERROR([No python2 interpreter found. PYTHON2 can be set to override default interpreter path])<br>
+ ])<br>
+ ], [<br>
+ AC_MSG_CHECKING([for python2 lttng-ust agent])<br>
+ AS_IF([$PYTHON2_BIN -c "import $UST_PYTHON_AGENT" 2>/dev/null], [<br>
+ PYTHON2_AGENT=$PYTHON2_BIN<br>
+ AC_MSG_RESULT([yes])<br>
+ RUN_PYTHON_AGENT_TEST=yes<br>
+ ], [<br>
+ AC_MSG_RESULT([no])<br>
+ AS_IF([test -z "$test_python2_agent_best_effort"],[<br>
+ AC_MSG_ERROR([No python2 agent found. PYTHONPATH env. variable can be set with the path to the agent.])<br>
+ ])<br>
+ ])<br>
+<br>
+ ])<br>
+<br>
+])<br>
+<br>
+AS_IF([test "x$enable_test_python3_agent" = "xyes" -o "x$test_python3_agent_best_effort" = "xyes" ], [<br>
+ AS_IF([test -z "$PYTHON3"], [<br>
+ PYTHON3=python3<br>
+ ], [<br>
+ AC_MSG_WARN([Using user-defined PYTHON3 ($PYTHON3) for lttng-ust python3 agent check])<br>
+ ])<br>
+<br>
+ AC_PATH_PROG([PYTHON3_BIN],[$PYTHON3])<br>
+ AS_IF([test -z "$PYTHON3_BIN"], [<br>
+ AS_IF([test -z "$test_python3_agent_best_effort"],[<br>
+ AC_MSG_ERROR([No python3 interpreter found. PYTHON3 can be set to override default interpreter path])<br>
+ ])<br>
+ ], [<br>
+ AC_MSG_CHECKING([for python3 lttng-ust agent])<br>
+ AS_IF([$PYTHON3_BIN -c "import $UST_PYTHON_AGENT" 2>/dev/null], [<br>
+ PYTHON3_AGENT=$PYTHON3_BIN<br>
+ AC_MSG_RESULT([yes])<br>
+ RUN_PYTHON_AGENT_TEST=yes<br>
+ ], [<br>
+ AC_MSG_RESULT([no])<br>
+ AS_IF([test -z "$test_python3_agent_best_effort"],[<br>
+ AC_MSG_ERROR([No python3 agent found. PYTHONPATH env. variable can be set with the path to the agent.])<br>
+ ])<br>
+ ])<br>
+<br>
+ ])<br>
+])<br>
+<br>
+AC_SUBST([RUN_PYTHON_AGENT_TEST])<br>
+AC_SUBST([PYTHON2_AGENT])<br>
+AC_SUBST([PYTHON3_AGENT])<br>
+<br>
AC_SYS_LARGEFILE<br>
<br>
# C compiler tests<br>
@@ -548,6 +645,9 @@ AC_CONFIG_FILES([<br>
tests/utils/testapp/gen-ust-tracef/Makefile<br>
])<br>
<br>
+# Inject variable into python test script<br>
+AC_CONFIG_FILES([tests/regression/ust/python-logging/test_python_logging],[chmod +x tests/regression/ust/python-logging/test_python_logging])<br>
+<br>
AC_OUTPUT<br>
<br>
#<br>
@@ -621,6 +721,25 @@ AS_IF([test "x$consumerd_only" = "xyes"],[<br>
AS_ECHO("All binaries will be built.")<br>
])<br>
<br>
+<br>
+# Info on optionnal test suites.<br>
+AS_ECHO()<br>
+AS_ECHO("Additional test suites to be run on make check":)<br></blockquote><div><br></div><div>Looks good to me except this part. Can you modify this to report whether or not the tests will run like we do for JUL and Log4j?</div><div><br></div><div><div>LTTng-UST Java agent JUL tests: Disabled</div><div>LTTng-UST Java agent Log4j tests: Disabled</div></div><div>etc.</div><div><br></div><div>Regards,</div><div>Jérémie</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+AS_ECHO_N("Python2 agent: ")<br>
+AS_IF([test ! -z "$PYTHON2_AGENT"],[<br>
+ AS_ECHO("yes")<br>
+],[<br>
+ AS_ECHO("no")<br>
+])<br>
+<br>
+AS_ECHO_N("Python3 agent: ")<br>
+AS_IF([test ! -z "$PYTHON3_AGENT"],[<br>
+ AS_ECHO("yes")<br>
+],[<br>
+ AS_ECHO("no")<br>
+])<br>
+<br>
# Print the bindir and libdir this `make install' will install into.<br>
AS_ECHO()<br>
AS_ECHO_N("Binaries will be installed in: ")<br>
diff --git a/tests/regression/ust/python-logging/test_python_logging b/tests/regression/ust/python-logging/test_python_logging<br>
deleted file mode 100755<br>
index b4fb410..0000000<br>
--- a/tests/regression/ust/python-logging/test_python_logging<br>
+++ /dev/null<br>
@@ -1,603 +0,0 @@<br>
-#!/bin/bash<br>
-#<br>
-# Copyright (C) - 2015 Philippe Proulx <<a href="mailto:pproulx@efficios.com">pproulx@efficios.com</a>><br>
-# Copyright (C) - 2014 David Goulet <<a href="mailto:dgoulet@efficios.com">dgoulet@efficios.com</a>><br>
-#<br>
-# This program is free software; you can redistribute it and/or modify it under<br>
-# the terms of the GNU General Public License, version 2 only, as published by<br>
-# the Free Software Foundation.<br>
-#<br>
-# This program is distributed in the hope that it will be useful, but WITHOUT<br>
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS<br>
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more<br>
-# details.<br>
-#<br>
-# You should have received a copy of the GNU General Public License along with<br>
-# this program; if not, write to the Free Software Foundation, Inc., 51<br>
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<br>
-<br>
-TEST_DESC="Python support"<br>
-<br>
-CURDIR=$(dirname $0)/<br>
-TESTDIR=$CURDIR/../../..<br>
-NR_ITER=5<br>
-NR_SEC_WAIT=1<br>
-TESTAPP_NAME="test"<br>
-TESTAPP_BIN="$TESTAPP_NAME.py"<br>
-TESTAPP_PATH="$CURDIR"<br>
-SESSION_NAME="python-test"<br>
-EVENT_NAME="python-ev-test1"<br>
-EVENT_NAME2="python-ev-test2"<br>
-OUTPUT_DEST="/dev/null"<br>
-<br>
-NUM_TESTS=310<br>
-<br>
-source $TESTDIR/utils/utils.sh<br>
-<br>
-function run_app<br>
-{<br>
- local python=$1<br>
- local debug_tp=$2<br>
- local fire_second_tp=$3<br>
-<br>
- $python $TESTAPP_PATH/$TESTAPP_BIN $NR_ITER $NR_SEC_WAIT $debug_tp $fire_second_tp<br>
-}<br>
-<br>
-function run_app_background<br>
-{<br>
- run_app $@ &<br>
-}<br>
-<br>
-function enable_python_loglevel_only()<br>
-{<br>
- sess_name=$1<br>
- event_name="$2"<br>
- loglevel=$3<br>
- channel_name=$4<br>
-<br>
- if [ -z $channel_name ]; then<br>
- # default channel if none specified<br>
- chan=""<br>
- else<br>
- chan="-c $channel_name"<br>
- fi<br>
-<br>
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" $chan -s $sess_name -p >$OUTPUT_DEST<br>
- ok $? "Enable Python event $event_name for session $sess_name with loglevel-only $loglevel"<br>
-}<br>
-<br>
-function enable_python_filter()<br>
-{<br>
- local sess_name="$1"<br>
- local event_name="$2"<br>
- local filter="$3"<br>
-<br>
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -p --filter "$filter" >/dev/null 2>&1<br>
- ok $? "Enable event $event_name with filter $filter for session $sess_name"<br>
-}<br>
-<br>
-function enable_python_filter_loglevel_only()<br>
-{<br>
- local sess_name="$1"<br>
- local event_name="$2"<br>
- local filter="$3"<br>
- local loglevel="$4"<br>
-<br>
- $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST<br>
- ok $? "Enable event $event_name with filter \"$filter\" and loglevel-only $loglevel for session $sess_name"<br>
-}<br>
-<br>
-# MUST set TESTDIR before calling those functions<br>
-<br>
-function test_python_before_start ()<br>
-{<br>
- diag "Test Python application BEFORE tracing starts"<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
-<br>
- # Run 5 times with a 1 second delay<br>
- run_app_background $1<br>
-<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Wait for the applications started in background<br>
- wait<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting all events.<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_after_start ()<br>
-{<br>
- diag "Test Python application AFTER tracing starts"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay<br>
- run_app $1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting all events.<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_loglevel ()<br>
-{<br>
- diag "Test Python application with loglevel"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
- enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay<br>
- run_app $1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting all events.<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- diag "Test Python applications with lower loglevel"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
- enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "CRITICAL"<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay<br>
- run_app $1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting 0 events.<br>
- trace_match_only $EVENT_NAME 0 $TRACE_PATH<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- diag "Test Python applications with higher loglevel"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
- enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay<br>
- run_app $1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting all events.<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH<br>
- return $?<br>
-}<br>
-<br>
-function test_python_loglevel_multiple ()<br>
-{<br>
- diag "Test Python application with multiple loglevel"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
- enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"<br>
- enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay and fire two TP.<br>
- run_app $1 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting all events times two.<br>
- trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
- enable_python_lttng_event_loglevel $SESSION_NAME '*' "INFO"<br>
- enable_python_lttng_event_loglevel $SESSION_NAME '*' "DEBUG"<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay and fire two TP.<br>
- run_app $1 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting all events times two.<br>
- trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_multi_session_loglevel()<br>
-{<br>
- diag "Test Python with multiple session"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1<br>
- enable_python_loglevel_only $SESSION_NAME-1 '*' "INFO"<br>
- start_lttng_tracing_ok $SESSION_NAME-1<br>
-<br>
- create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2<br>
- enable_python_loglevel_only $SESSION_NAME-2 '*' "DEBUG"<br>
- start_lttng_tracing_ok $SESSION_NAME-2<br>
-<br>
- # Run 5 times with a 1 second delay and fire second TP.<br>
- run_app $1 1 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME-1<br>
- stop_lttng_tracing_ok $SESSION_NAME-2<br>
- destroy_lttng_session_ok $SESSION_NAME-1<br>
- destroy_lttng_session_ok $SESSION_NAME-2<br>
-<br>
- # Expecting NR_ITER events being the main event and the second tp one.<br>
- trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
- trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- # Expectin NR_ITER events being the debug TP.<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_multi_session_disable()<br>
-{<br>
- diag "Test Python with multiple session with disabled event"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1<br>
- enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME<br>
- enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME2<br>
- disable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME<br>
- start_lttng_tracing_ok $SESSION_NAME-1<br>
-<br>
- create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2<br>
- enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2<br>
- start_lttng_tracing_ok $SESSION_NAME-2<br>
-<br>
- # Run 5 times with a 1 second delay and fire second TP.<br>
- run_app $1 0 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME-1<br>
- stop_lttng_tracing_ok $SESSION_NAME-2<br>
- destroy_lttng_session_ok $SESSION_NAME-1<br>
- destroy_lttng_session_ok $SESSION_NAME-2<br>
-<br>
- # Validate test. Expecting one event of the second TP.<br>
- trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- # Validate test. Expecting one event of the second TP.<br>
- trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_multi_session_disable_wildcard()<br>
-{<br>
- diag "Test Python with multiple session with disabled wildcard event"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1<br>
- enable_python_lttng_event $SESSION_NAME-1 '*'<br>
-<br>
- create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2<br>
- enable_python_lttng_event $SESSION_NAME-2 '*'<br>
-<br>
- disable_python_lttng_event $SESSION_NAME-1 '*'<br>
-<br>
- start_lttng_tracing_ok $SESSION_NAME-1<br>
- start_lttng_tracing_ok $SESSION_NAME-2<br>
-<br>
- run_app $1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME-1<br>
- stop_lttng_tracing_ok $SESSION_NAME-2<br>
- destroy_lttng_session_ok $SESSION_NAME-1<br>
- destroy_lttng_session_ok $SESSION_NAME-2<br>
-<br>
- # Validate test. Expecting NO event of the first TP.<br>
- trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- # Validate test. Expecting all events of the first TP.<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_disable_all()<br>
-{<br>
- diag "Test Python with multiple session with disabled all event"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
- enable_python_lttng_event $SESSION_NAME '*'<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME2<br>
-<br>
- disable_python_lttng_event $SESSION_NAME '*'<br>
-<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- run_app $1 0 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting NO event of the first TP and second TP.<br>
- trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME<br>
- trace_match_only $EVENT_NAME2 0 $TRACE_PATH/$SESSION_NAME<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_multi_session()<br>
-{<br>
- diag "Test Python with multiple session"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1<br>
- enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME<br>
- start_lttng_tracing_ok $SESSION_NAME-1<br>
-<br>
- create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2<br>
- enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2<br>
- start_lttng_tracing_ok $SESSION_NAME-2<br>
-<br>
- # Run 5 times with a 1 second delay and fire second TP.<br>
- run_app $1 0 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME-1<br>
- stop_lttng_tracing_ok $SESSION_NAME-2<br>
- destroy_lttng_session_ok $SESSION_NAME-1<br>
- destroy_lttng_session_ok $SESSION_NAME-2<br>
-<br>
- # Validate test. Expecting all events of first TP<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- # Validate test. Expecting one event of the second TP.<br>
- trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_destroy_session()<br>
-{<br>
- diag "Test Python two session with destroy"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH/first-sess<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay<br>
- run_app_background $1 0 1<br>
-<br>
- # Wait for the applications started in background<br>
- wait<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting at least one event num 1<br>
- validate_trace $EVENT_NAME $TRACE_PATH/first-sess<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH/second-sess<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME2<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay<br>
- run_app_background $1 0 1<br>
-<br>
- # Wait for the applications started in background<br>
- wait<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting only one event num 2<br>
- trace_match_only $EVENT_NAME2 1 $TRACE_PATH/second-sess<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_filtering()<br>
-{<br>
- diag "Test Python filtering"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
- # Enable all event with a filter.<br>
- enable_python_filter $SESSION_NAME '*' 'msg == "python-ev-test2 fired [INFO]"'<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay and fire second TP.<br>
- run_app $1 0 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting one event of the second TP only.<br>
- trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
- # Enable first Logger but filter msg payload for the INFO one while<br>
- # triggering the debug and second TP.<br>
- enable_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired" [INFO]'<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay, fire debug and second TP.<br>
- run_app $1 1 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting NR_ITER event of the main INFO tp.<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_disable()<br>
-{<br>
- diag "Test Python disable event"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
- # Enable all event with a filter.<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME2<br>
- disable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay and fire second TP.<br>
- run_app $1 0 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting one event of the second TP only.<br>
- trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_disable_enable()<br>
-{<br>
- diag "Test Python disable event followed by an enable"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
- # Enable all event with a filter.<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
- disable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
- enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay and fire second TP.<br>
- run_app $1 0 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting NR_ITER event of the main INFO tp.<br>
- trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-function test_python_filter_loglevel()<br>
-{<br>
- local BOGUS_EVENT_NAME="not_a_real_event"<br>
- local FILTER="int_loglevel > 30 || int_loglevel < 30"<br>
- local ALL_EVENTS="."<br>
-<br>
- diag "Test Python a filter with a loglevel"<br>
-<br>
- create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
- # Enable an event with a filter and the loglevel-only option.<br>
- enable_python_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" "INFO"<br>
- disable_python_lttng_event $SESSION_NAME $BOGUS_EVENT_NAME<br>
- enable_python_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" "INFO"<br>
- start_lttng_tracing_ok $SESSION_NAME<br>
-<br>
- # Run 5 times with a 1 second delay and fire second TP.<br>
- run_app $1 0 1<br>
-<br>
- stop_lttng_tracing_ok $SESSION_NAME<br>
- destroy_lttng_session_ok $SESSION_NAME<br>
-<br>
- # Validate test. Expecting no events.<br>
- trace_match_only $ALL_EVENTS 0 $TRACE_PATH/$SESSION_NAME<br>
- if [ $? -ne 0 ]; then<br>
- return $?<br>
- fi<br>
-}<br>
-<br>
-plan_tests $NUM_TESTS<br>
-<br>
-print_test_banner "$TEST_DESC"<br>
-<br>
-if [ ! -f "$TESTAPP_BIN" ]; then<br>
- withapp=0<br>
-else<br>
- withapp=1<br>
-fi<br>
-<br>
-skip $withapp "Python support is needed. Skipping all tests." $NUM_TESTS ||<br>
-{<br>
- start_lttng_sessiond<br>
-<br>
- tests=(<br>
- test_python_multi_session_disable_wildcard<br>
- test_python_multi_session_disable<br>
- test_python_disable<br>
- test_python_disable_enable<br>
- test_python_disable_all<br>
- test_python_filtering<br>
- test_python_multi_session_loglevel<br>
- test_python_destroy_session<br>
- test_python_loglevel<br>
- test_python_loglevel_multiple<br>
- test_python_before_start<br>
- test_python_after_start<br>
- test_python_multi_session<br>
- test_python_filter_loglevel<br>
- )<br>
-<br>
- for python_version in 2 3;<br>
- do<br>
- for fct_test in ${tests[@]};<br>
- do<br>
- TRACE_PATH=$(mktemp -d)<br>
-<br>
- diag "(Python $python_version)"<br>
- ${fct_test} python$python_version<br>
- if [ $? -ne 0 ]; then<br>
- break;<br>
- fi<br>
- rm -rf $TRACE_PATH<br>
- done<br>
- done<br>
-<br>
- stop_lttng_sessiond<br>
-}<br>
diff --git a/tests/regression/ust/python-logging/<a href="http://test_python_logging.in" rel="noreferrer" target="_blank">test_python_logging.in</a> b/tests/regression/ust/python-logging/<a href="http://test_python_logging.in" rel="noreferrer" target="_blank">test_python_logging.in</a><br>
new file mode 100755<br>
index 0000000..8aff408<br>
--- /dev/null<br>
+++ b/tests/regression/ust/python-logging/<a href="http://test_python_logging.in" rel="noreferrer" target="_blank">test_python_logging.in</a><br>
@@ -0,0 +1,610 @@<br>
+#!/bin/bash<br>
+#<br>
+# Copyright (C) - 2015 Philippe Proulx <<a href="mailto:pproulx@efficios.com">pproulx@efficios.com</a>><br>
+# Copyright (C) - 2014 David Goulet <<a href="mailto:dgoulet@efficios.com">dgoulet@efficios.com</a>><br>
+#<br>
+# This program is free software; you can redistribute it and/or modify it under<br>
+# the terms of the GNU General Public License, version 2 only, as published by<br>
+# the Free Software Foundation.<br>
+#<br>
+# This program is distributed in the hope that it will be useful, but WITHOUT<br>
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS<br>
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more<br>
+# details.<br>
+#<br>
+# You should have received a copy of the GNU General Public License along with<br>
+# this program; if not, write to the Free Software Foundation, Inc., 51<br>
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<br>
+<br>
+TEST_DESC="Python support"<br>
+<br>
+CURDIR=$(dirname $0)/<br>
+TESTDIR=$CURDIR/../../..<br>
+NR_ITER=5<br>
+NR_SEC_WAIT=0<br>
+TESTAPP_NAME="test"<br>
+TESTAPP_BIN="$TESTAPP_NAME.py"<br>
+TESTAPP_PATH="$CURDIR"<br>
+SESSION_NAME="python-test"<br>
+EVENT_NAME="python-ev-test1"<br>
+EVENT_NAME2="python-ev-test2"<br>
+OUTPUT_DEST="/dev/null"<br>
+<br>
+python_versions=(@PYTHON2_AGENT@ @PYTHON3_AGENT@)<br>
+run_test=@RUN_PYTHON_AGENT_TEST@<br>
+<br>
+if [[ -z "$run_test" ]]; then<br>
+ NUM_TESTS=1<br>
+else<br>
+ NUM_TESTS=$(((154 * ${#python_versions[@]})+2))<br>
+fi<br>
+<br>
+source $TESTDIR/utils/utils.sh<br>
+<br>
+function run_app<br>
+{<br>
+ local python=$1<br>
+ local debug_tp=$2<br>
+ local fire_second_tp=$3<br>
+<br>
+ $python $TESTAPP_PATH/$TESTAPP_BIN $NR_ITER $NR_SEC_WAIT $debug_tp $fire_second_tp<br>
+}<br>
+<br>
+function run_app_background<br>
+{<br>
+ run_app $@ &<br>
+}<br>
+<br>
+function enable_python_loglevel_only()<br>
+{<br>
+ sess_name=$1<br>
+ event_name="$2"<br>
+ loglevel=$3<br>
+ channel_name=$4<br>
+<br>
+ if [ -z $channel_name ]; then<br>
+ # default channel if none specified<br>
+ chan=""<br>
+ else<br>
+ chan="-c $channel_name"<br>
+ fi<br>
+<br>
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" $chan -s $sess_name -p >$OUTPUT_DEST<br>
+ ok $? "Enable Python event $event_name for session $sess_name with loglevel-only $loglevel"<br>
+}<br>
+<br>
+function enable_python_filter()<br>
+{<br>
+ local sess_name="$1"<br>
+ local event_name="$2"<br>
+ local filter="$3"<br>
+<br>
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST<br>
+ ok $? "Enable event $event_name with filter $filter for session $sess_name"<br>
+}<br>
+<br>
+function enable_python_filter_loglevel_only()<br>
+{<br>
+ local sess_name="$1"<br>
+ local event_name="$2"<br>
+ local filter="$3"<br>
+ local loglevel="$4"<br>
+<br>
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event --loglevel-only $loglevel "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST<br>
+ ok $? "Enable event $event_name with filter \"$filter\" and loglevel-only $loglevel for session $sess_name"<br>
+}<br>
+<br>
+# MUST set TESTDIR before calling those functions<br>
+<br>
+function test_python_before_start ()<br>
+{<br>
+ diag "Test Python application BEFORE tracing starts"<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay<br>
+ run_app_background $1<br>
+<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Wait for the applications started in background<br>
+ wait<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting all events.<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_after_start ()<br>
+{<br>
+ diag "Test Python application AFTER tracing starts"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay<br>
+ run_app $1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting all events.<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_loglevel ()<br>
+{<br>
+ diag "Test Python application with loglevel"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay<br>
+ run_app $1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting all events.<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ diag "Test Python applications with lower loglevel"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "CRITICAL"<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay<br>
+ run_app $1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting 0 events.<br>
+ trace_match_only $EVENT_NAME 0 $TRACE_PATH<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ diag "Test Python applications with higher loglevel"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay<br>
+ run_app $1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting all events.<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH<br>
+ return $?<br>
+}<br>
+<br>
+function test_python_loglevel_multiple ()<br>
+{<br>
+ diag "Test Python application with multiple loglevel"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "INFO"<br>
+ enable_python_lttng_event_loglevel $SESSION_NAME $EVENT_NAME "DEBUG"<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay and fire two TP.<br>
+ run_app $1 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting all events times two.<br>
+ trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH<br>
+ enable_python_lttng_event_loglevel $SESSION_NAME '*' "INFO"<br>
+ enable_python_lttng_event_loglevel $SESSION_NAME '*' "DEBUG"<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay and fire two TP.<br>
+ run_app $1 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting all events times two.<br>
+ trace_match_only $EVENT_NAME $(($NR_ITER * 2)) $TRACE_PATH<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_multi_session_loglevel()<br>
+{<br>
+ diag "Test Python with multiple session"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1<br>
+ enable_python_loglevel_only $SESSION_NAME-1 '*' "INFO"<br>
+ start_lttng_tracing_ok $SESSION_NAME-1<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2<br>
+ enable_python_loglevel_only $SESSION_NAME-2 '*' "DEBUG"<br>
+ start_lttng_tracing_ok $SESSION_NAME-2<br>
+<br>
+ # Run 5 times with a 1 second delay and fire second TP.<br>
+ run_app $1 1 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME-1<br>
+ stop_lttng_tracing_ok $SESSION_NAME-2<br>
+ destroy_lttng_session_ok $SESSION_NAME-1<br>
+ destroy_lttng_session_ok $SESSION_NAME-2<br>
+<br>
+ # Expecting NR_ITER events being the main event and the second tp one.<br>
+ trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+ trace_matches $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ # Expectin NR_ITER events being the debug TP.<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_multi_session_disable()<br>
+{<br>
+ diag "Test Python with multiple session with disabled event"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1<br>
+ enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME<br>
+ enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME2<br>
+ disable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME<br>
+ start_lttng_tracing_ok $SESSION_NAME-1<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2<br>
+ enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2<br>
+ start_lttng_tracing_ok $SESSION_NAME-2<br>
+<br>
+ # Run 5 times with a 1 second delay and fire second TP.<br>
+ run_app $1 0 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME-1<br>
+ stop_lttng_tracing_ok $SESSION_NAME-2<br>
+ destroy_lttng_session_ok $SESSION_NAME-1<br>
+ destroy_lttng_session_ok $SESSION_NAME-2<br>
+<br>
+ # Validate test. Expecting one event of the second TP.<br>
+ trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-1<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ # Validate test. Expecting one event of the second TP.<br>
+ trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_multi_session_disable_wildcard()<br>
+{<br>
+ diag "Test Python with multiple session with disabled wildcard event"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1<br>
+ enable_python_lttng_event $SESSION_NAME-1 '*'<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2<br>
+ enable_python_lttng_event $SESSION_NAME-2 '*'<br>
+<br>
+ disable_python_lttng_event $SESSION_NAME-1 '*'<br>
+<br>
+ start_lttng_tracing_ok $SESSION_NAME-1<br>
+ start_lttng_tracing_ok $SESSION_NAME-2<br>
+<br>
+ run_app $1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME-1<br>
+ stop_lttng_tracing_ok $SESSION_NAME-2<br>
+ destroy_lttng_session_ok $SESSION_NAME-1<br>
+ destroy_lttng_session_ok $SESSION_NAME-2<br>
+<br>
+ # Validate test. Expecting NO event of the first TP.<br>
+ trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME-1<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ # Validate test. Expecting all events of the first TP.<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-2<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_disable_all()<br>
+{<br>
+ diag "Test Python with multiple session with disabled all event"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
+ enable_python_lttng_event $SESSION_NAME '*'<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME2<br>
+<br>
+ disable_python_lttng_event $SESSION_NAME '*'<br>
+<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ run_app $1 0 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting NO event of the first TP and second TP.<br>
+ trace_match_only $EVENT_NAME 0 $TRACE_PATH/$SESSION_NAME<br>
+ trace_match_only $EVENT_NAME2 0 $TRACE_PATH/$SESSION_NAME<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_multi_session()<br>
+{<br>
+ diag "Test Python with multiple session"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME-1 $TRACE_PATH/$SESSION_NAME-1<br>
+ enable_python_lttng_event $SESSION_NAME-1 $EVENT_NAME<br>
+ start_lttng_tracing_ok $SESSION_NAME-1<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME-2 $TRACE_PATH/$SESSION_NAME-2<br>
+ enable_python_lttng_event $SESSION_NAME-2 $EVENT_NAME2<br>
+ start_lttng_tracing_ok $SESSION_NAME-2<br>
+<br>
+ # Run 5 times with a 1 second delay and fire second TP.<br>
+ run_app $1 0 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME-1<br>
+ stop_lttng_tracing_ok $SESSION_NAME-2<br>
+ destroy_lttng_session_ok $SESSION_NAME-1<br>
+ destroy_lttng_session_ok $SESSION_NAME-2<br>
+<br>
+ # Validate test. Expecting all events of first TP<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME-1<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ # Validate test. Expecting one event of the second TP.<br>
+ trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME-2<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_destroy_session()<br>
+{<br>
+ diag "Test Python two session with destroy"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH/first-sess<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay<br>
+ run_app_background $1 0 1<br>
+<br>
+ # Wait for the applications started in background<br>
+ wait<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting at least one event num 1<br>
+ validate_trace $EVENT_NAME $TRACE_PATH/first-sess<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH/second-sess<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME2<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay<br>
+ run_app_background $1 0 1<br>
+<br>
+ # Wait for the applications started in background<br>
+ wait<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting only one event num 2<br>
+ trace_match_only $EVENT_NAME2 1 $TRACE_PATH/second-sess<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_filtering()<br>
+{<br>
+ diag "Test Python filtering"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
+ # Enable all event with a filter.<br>
+ enable_python_filter $SESSION_NAME '*' 'msg == "python-ev-test2 fired [INFO]"'<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay and fire second TP.<br>
+ run_app $1 0 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting one event of the second TP only.<br>
+ trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
+ # Enable first Logger but filter msg payload for the INFO one while<br>
+ # triggering the debug and second TP.<br>
+ enable_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired [INFO]"'<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay, fire debug and second TP.<br>
+ run_app $1 1 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting NR_ITER event of the main INFO tp.<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_disable()<br>
+{<br>
+ diag "Test Python disable event"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
+ # Enable all event with a filter.<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME2<br>
+ disable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay and fire second TP.<br>
+ run_app $1 0 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting one event of the second TP only.<br>
+ trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_disable_enable()<br>
+{<br>
+ diag "Test Python disable event followed by an enable"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
+ # Enable all event with a filter.<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+ disable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+ enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay and fire second TP.<br>
+ run_app $1 0 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting NR_ITER event of the main INFO tp.<br>
+ trace_match_only $EVENT_NAME $NR_ITER $TRACE_PATH/$SESSION_NAME<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+function test_python_filter_loglevel()<br>
+{<br>
+ local BOGUS_EVENT_NAME="not_a_real_event"<br>
+ local FILTER="int_loglevel > 30 || int_loglevel < 30"<br>
+ local ALL_EVENTS="."<br>
+<br>
+ diag "Test Python a filter with a loglevel"<br>
+<br>
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
+ # Enable an event with a filter and the loglevel-only option.<br>
+ enable_python_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" "INFO"<br>
+ disable_python_lttng_event $SESSION_NAME $BOGUS_EVENT_NAME<br>
+ enable_python_filter_loglevel_only $SESSION_NAME $BOGUS_EVENT_NAME "$FILTER" "INFO"<br>
+ start_lttng_tracing_ok $SESSION_NAME<br>
+<br>
+ # Run 5 times with a 1 second delay and fire second TP.<br>
+ run_app $1 0 1<br>
+<br>
+ stop_lttng_tracing_ok $SESSION_NAME<br>
+ destroy_lttng_session_ok $SESSION_NAME<br>
+<br>
+ # Validate test. Expecting no events.<br>
+ trace_match_only $ALL_EVENTS 0 $TRACE_PATH/$SESSION_NAME<br>
+ if [ $? -ne 0 ]; then<br>
+ return $?<br>
+ fi<br>
+}<br>
+<br>
+plan_tests $NUM_TESTS<br>
+<br>
+print_test_banner "$TEST_DESC"<br>
+<br>
+if [[ ${#python_versions[@]} -eq 0 || "x$run_test" != "xyes" ]]; then<br>
+ skip_agent=0<br>
+else<br>
+ skip_agent=1<br>
+fi<br>
+<br>
+skip $skip_agent "Python agent test skipped." $NUM_TESTS ||<br>
+{<br>
+ start_lttng_sessiond<br>
+<br>
+ tests=(<br>
+ test_python_multi_session_disable_wildcard<br>
+ test_python_multi_session_disable<br>
+ test_python_disable<br>
+ test_python_disable_enable<br>
+ test_python_disable_all<br>
+ test_python_filtering<br>
+ test_python_multi_session_loglevel<br>
+ test_python_destroy_session<br>
+ test_python_loglevel<br>
+ test_python_loglevel_multiple<br>
+ test_python_before_start<br>
+ test_python_after_start<br>
+ test_python_multi_session<br>
+ test_python_filter_loglevel<br>
+ )<br>
+<br>
+<br>
+ for python_version in ${python_versions[*]};<br>
+ do<br>
+ for fct_test in ${tests[@]};<br>
+ do<br>
+ TRACE_PATH=$(mktemp -d)<br>
+<br>
+ diag "(Python $python_version)"<br>
+ ${fct_test} $python_version<br>
+ if [ $? -ne 0 ]; then<br>
+ break;<br>
+ fi<br>
+ rm -rf $TRACE_PATH<br>
+ done<br>
+ done<br>
+ stop_lttng_sessiond<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.4<br>
<br>
<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div></div>