<div dir="ltr">Merged, thanks!<div><br></div><div>Jérémie</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 31, 2015 at 8:10 PM, Philippe Proulx <span dir="ltr"><<a href="mailto:eeppeliteloop@gmail.com" target="_blank">eeppeliteloop@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch makes the tests follow the recent refactoring<br>
of the LTTng-UST Python agent.<br>
<br>
You need both python2 and python3 in your $PATH to run this<br>
test now (since the agent is compatible with both versions<br>
of Python).<br>
<br>
Signed-off-by: Philippe Proulx <<a href="mailto:eeppeliteloop@gmail.com">eeppeliteloop@gmail.com</a>><br>
---<br>
tests/regression/ust/python-logging/LTTngTest.py | 76 ----------------------<br>
tests/regression/ust/python-logging/test.py | 71 ++++++++++++++++++++<br>
.../ust/python-logging/test_python_logging | 76 ++++++++++++----------<br>
3 files changed, 112 insertions(+), 111 deletions(-)<br>
delete mode 100644 tests/regression/ust/python-logging/LTTngTest.py<br>
create mode 100644 tests/regression/ust/python-logging/test.py<br>
<br>
diff --git a/tests/regression/ust/python-logging/LTTngTest.py b/tests/regression/ust/python-logging/LTTngTest.py<br>
deleted file mode 100644<br>
index a3ed8f9..0000000<br>
--- a/tests/regression/ust/python-logging/LTTngTest.py<br>
+++ /dev/null<br>
@@ -1,76 +0,0 @@<br>
-#!/usr/bin/env python<br>
-#<br>
-# Copyright (C) 2014 - David Goulet <<a href="mailto:dgoulet@efficios.com">dgoulet@efficios.com</a>><br>
-#<br>
-# This library is free software; you can redistribute it and/or modify it under<br>
-# the terms of the GNU Lesser General Public License as published by the Free<br>
-# Software Foundation; version 2.1 of the License.<br>
-#<br>
-# This library 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 Lesser General Public License for more<br>
-# details.<br>
-#<br>
-# You should have received a copy of the GNU Lesser General Public License<br>
-# along with this library; if not, write to the Free Software Foundation, Inc.,<br>
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA<br>
-<br>
-import sys<br>
-import logging<br>
-import errno<br>
-<br>
-from time import sleep<br>
-<br>
-def cleanup(code, agent = None):<br>
- """<br>
- Cleanup agent and exit with given code.<br>
- """<br>
- if agent is not None:<br>
- agent.destroy()<br>
-<br>
- sys.exit(code)<br>
-<br>
-try:<br>
- import lttng_agent<br>
-except ImportError as e:<br>
- print("LTTng Agent not found. Aborting")<br>
- cleanup(errno.ENOSYS)<br>
-<br>
-def run():<br>
- """<br>
- Main for this test program. Based on the Java testing program that behaves<br>
- exactly the same.<br>
- """<br>
-<br>
- agent = lttng_agent.LTTngAgent()<br>
- ev1 = logging.getLogger("python-ev-test1");<br>
- ev2 = logging.getLogger("python-ev-test2");<br>
-<br>
- try:<br>
- nr_iter = int(sys.argv[1])<br>
- wait_time = int(sys.argv[2])<br>
- fire_debug_ev = 0<br>
- fire_second_ev = 0<br>
- except IndexError as e:<br>
- print("Missing arguments. Aborting")<br>
- cleanup(errno.EINVAL, agent)<br>
- except ValueError as e:<br>
- print("Invalid arguments. Aborting")<br>
- cleanup(errno.EINVAL, agent)<br>
-<br>
- if len(sys.argv) > 3:<br>
- fire_debug_ev = int(sys.argv[3])<br>
- if len(sys.argv) > 4:<br>
- fire_second_ev = int(sys.argv[4])<br>
-<br>
- for i in range(0, nr_iter):<br>
- <a href="http://ev1.info" rel="noreferrer" target="_blank">ev1.info</a>("%s fired" % <a href="http://ev1.name" rel="noreferrer" target="_blank">ev1.name</a>)<br>
- if fire_debug_ev != 0:<br>
- ev1.debug("%s DEBUG fired" % <a href="http://ev1.name" rel="noreferrer" target="_blank">ev1.name</a>)<br>
- sleep(wait_time)<br>
-<br>
- if fire_second_ev != 0:<br>
- <a href="http://ev2.info" rel="noreferrer" target="_blank">ev2.info</a>("%s fired" % <a href="http://ev2.name" rel="noreferrer" target="_blank">ev2.name</a>)<br>
-<br>
-if __name__ == "__main__":<br>
- run()<br>
diff --git a/tests/regression/ust/python-logging/test.py b/tests/regression/ust/python-logging/test.py<br>
new file mode 100644<br>
index 0000000..d08e623<br>
--- /dev/null<br>
+++ b/tests/regression/ust/python-logging/test.py<br>
@@ -0,0 +1,71 @@<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 library is free software; you can redistribute it and/or modify it under<br>
+# the terms of the GNU Lesser General Public License as published by the Free<br>
+# Software Foundation; version 2.1 of the License.<br>
+#<br>
+# This library 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 Lesser General Public License for more<br>
+# details.<br>
+#<br>
+# You should have received a copy of the GNU Lesser General Public License<br>
+# along with this library; if not, write to the Free Software Foundation, Inc.,<br>
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA<br>
+<br>
+from __future__ import unicode_literals, print_function<br>
+import logging<br>
+import time<br>
+import sys<br>
+<br>
+<br>
+def _perror(msg):<br>
+ print(msg, file=sys.stderr)<br>
+ sys.exit(1)<br>
+<br>
+<br>
+try:<br>
+ import lttngust<br>
+except (ImportError) as e:<br>
+ _perror('lttngust package not found: {}'.format(e))<br>
+<br>
+<br>
+def _main():<br>
+ ev1 = logging.getLogger('python-ev-test1');<br>
+ ev2 = logging.getLogger('python-ev-test2');<br>
+<br>
+ logging.basicConfig()<br>
+<br>
+ try:<br>
+ nr_iter = int(sys.argv[1])<br>
+ wait_time = float(sys.argv[2])<br>
+ fire_debug_ev = False<br>
+ fire_second_ev = False<br>
+ except (IndexError) as e:<br>
+ _perror('missing arguments: {}'.format(e))<br>
+ except (ValueError) as e:<br>
+ _perror('invalid arguments: {}'.format(e))<br>
+<br>
+ try:<br>
+ if len(sys.argv) > 3:<br>
+ fire_debug_ev = int(sys.argv[3])<br>
+ if len(sys.argv) > 4:<br>
+ fire_second_ev = int(sys.argv[4])<br>
+ except (ValueError) as e:<br>
+ _perror('invalid arguments: {}'.format(e))<br>
+<br>
+ for i in range(nr_iter):<br>
+ <a href="http://ev1.info" rel="noreferrer" target="_blank">ev1.info</a>('{} fired [INFO]'.format(<a href="http://ev1.name" rel="noreferrer" target="_blank">ev1.name</a>))<br>
+<br>
+ if fire_debug_ev:<br>
+ ev1.debug('{} fired [DEBUG]'.format(<a href="http://ev1.name" rel="noreferrer" target="_blank">ev1.name</a>))<br>
+<br>
+ time.sleep(wait_time)<br>
+<br>
+ if fire_second_ev:<br>
+ <a href="http://ev2.info" rel="noreferrer" target="_blank">ev2.info</a>('{} fired [INFO]'.format(<a href="http://ev2.name" rel="noreferrer" target="_blank">ev2.name</a>))<br>
+<br>
+<br>
+if __name__ == '__main__':<br>
+ _main()<br>
diff --git a/tests/regression/ust/python-logging/test_python_logging b/tests/regression/ust/python-logging/test_python_logging<br>
index cb960da..4c2a3c6 100755<br>
--- a/tests/regression/ust/python-logging/test_python_logging<br>
+++ b/tests/regression/ust/python-logging/test_python_logging<br>
@@ -1,5 +1,6 @@<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>
@@ -15,13 +16,13 @@<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="Java Python support"<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="LTTngTest"<br>
+TESTAPP_NAME="test"<br>
TESTAPP_BIN="$TESTAPP_NAME.py"<br>
TESTAPP_PATH="$CURDIR"<br>
SESSION_NAME="python-test"<br>
@@ -29,16 +30,17 @@ EVENT_NAME="python-ev-test1"<br>
EVENT_NAME2="python-ev-test2"<br>
OUTPUT_DEST="/dev/null"<br>
<br>
-NUM_TESTS=156<br>
+NUM_TESTS=310<br>
<br>
source $TESTDIR/utils/utils.sh<br>
<br>
function run_app<br>
{<br>
- local debug_tp=$1<br>
- local fire_second_tp=$2<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>
+ $python $TESTAPP_PATH/$TESTAPP_BIN $NR_ITER $NR_SEC_WAIT $debug_tp $fire_second_tp<br>
}<br>
<br>
function run_app_background<br>
@@ -94,7 +96,7 @@ function test_python_before_start ()<br>
enable_python_lttng_event $SESSION_NAME $EVENT_NAME<br>
<br>
# Run 5 times with a 1 second delay<br>
- run_app_background<br>
+ run_app_background $1<br>
<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
@@ -120,7 +122,7 @@ function test_python_after_start ()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay<br>
- run_app<br>
+ run_app $1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -141,7 +143,7 @@ function test_python_loglevel ()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay<br>
- run_app<br>
+ run_app $1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -159,7 +161,7 @@ function test_python_loglevel ()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay<br>
- run_app<br>
+ run_app $1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -177,7 +179,7 @@ function test_python_loglevel ()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay<br>
- run_app<br>
+ run_app $1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -197,7 +199,7 @@ function test_python_loglevel_multiple ()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay and fire two TP.<br>
- run_app 1<br>
+ run_app $1 1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -214,7 +216,7 @@ function test_python_loglevel_multiple ()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay and fire two TP.<br>
- run_app 1<br>
+ run_app $1 1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -239,7 +241,7 @@ function test_python_multi_session_loglevel()<br>
start_lttng_tracing $SESSION_NAME-2<br>
<br>
# Run 5 times with a 1 second delay and fire second TP.<br>
- run_app 1 1<br>
+ run_app $1 1 1<br>
<br>
stop_lttng_tracing $SESSION_NAME-1<br>
stop_lttng_tracing $SESSION_NAME-2<br>
@@ -278,7 +280,7 @@ function test_python_multi_session_disable()<br>
start_lttng_tracing $SESSION_NAME-2<br>
<br>
# Run 5 times with a 1 second delay and fire second TP.<br>
- run_app 0 1<br>
+ run_app $1 0 1<br>
<br>
stop_lttng_tracing $SESSION_NAME-1<br>
stop_lttng_tracing $SESSION_NAME-2<br>
@@ -313,7 +315,7 @@ function test_python_multi_session_disable_wildcard()<br>
start_lttng_tracing $SESSION_NAME-1<br>
start_lttng_tracing $SESSION_NAME-2<br>
<br>
- run_app<br>
+ run_app $1<br>
<br>
stop_lttng_tracing $SESSION_NAME-1<br>
stop_lttng_tracing $SESSION_NAME-2<br>
@@ -346,7 +348,7 @@ function test_python_disable_all()<br>
<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
- run_app 0 1<br>
+ run_app $1 0 1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -372,7 +374,7 @@ function test_python_multi_session()<br>
start_lttng_tracing $SESSION_NAME-2<br>
<br>
# Run 5 times with a 1 second delay and fire second TP.<br>
- run_app 0 1<br>
+ run_app $1 0 1<br>
<br>
stop_lttng_tracing $SESSION_NAME-1<br>
stop_lttng_tracing $SESSION_NAME-2<br>
@@ -401,7 +403,7 @@ function test_python_destroy_session()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay<br>
- run_app_background 0 1<br>
+ run_app_background $1 0 1<br>
<br>
# Wait for the applications started in background<br>
wait<br>
@@ -420,7 +422,7 @@ function test_python_destroy_session()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay<br>
- run_app_background 0 1<br>
+ run_app_background $1 0 1<br>
<br>
# Wait for the applications started in background<br>
wait<br>
@@ -441,11 +443,11 @@ function test_python_filtering()<br>
<br>
create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME<br>
# Enable all event with a filter.<br>
- enable_python_filter $SESSION_NAME '*' 'msg == "python-ev-test2 fired"'<br>
+ enable_python_filter $SESSION_NAME '*' 'msg == "python-ev-test2 fired [INFO]"'<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay and fire second TP.<br>
- run_app 0 1<br>
+ run_app $1 0 1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -459,11 +461,11 @@ function test_python_filtering()<br>
create_lttng_session $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"'<br>
+ enable_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired [INFO]"'<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay, fire debug and second TP.<br>
- run_app 1 1<br>
+ run_app $1 1 1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -487,7 +489,7 @@ function test_python_disable()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay and fire second TP.<br>
- run_app 0 1<br>
+ run_app $1 0 1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -511,7 +513,7 @@ function test_python_disable_enable()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay and fire second TP.<br>
- run_app 0 1<br>
+ run_app $1 0 1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -539,7 +541,7 @@ function test_python_filter_loglevel()<br>
start_lttng_tracing $SESSION_NAME<br>
<br>
# Run 5 times with a 1 second delay and fire second TP.<br>
- run_app 0 1<br>
+ run_app $1 0 1<br>
<br>
stop_lttng_tracing $SESSION_NAME<br>
destroy_lttng_session $SESSION_NAME<br>
@@ -582,15 +584,19 @@ skip $withapp "Python support is needed. Skipping all tests." $NUM_TESTS ||<br>
test_python_filter_loglevel<br>
)<br>
<br>
- for fct_test in ${tests[@]};<br>
+ for python_version in 2 3;<br>
do<br>
- TRACE_PATH=$(mktemp -d)<br>
-<br>
- ${fct_test}<br>
- if [ $? -ne 0 ]; then<br>
- break;<br>
- fi<br>
- rm -rf $TRACE_PATH<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>
<span class="HOEnZb"><font color="#888888">--<br>
2.3.0<br>
<br>
<br>
_______________________________________________<br>
lttng-dev mailing list<br>
<a href="mailto:lttng-dev@lists.lttng.org">lttng-dev@lists.lttng.org</a><br>
<a href="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev" rel="noreferrer" target="_blank">http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</a><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>