From 9586c1988d30b9729731a785108cde14990e50dd Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Mon, 24 Aug 2015 08:08:29 -0700 Subject: [PATCH] Fix: Python agent tests are always skipped MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit v2: Change the configure report section to emulate the java ust agent test reporting. Introduce --enable-test-python{2,3}-agent and --enable-test-python-agent-all flag on configure. Configure searches for the python agent for both Python 2 and 3 and enables or skips their associated tests based on the result. When using the --enable-test-python{2,3}-agent & --enable-test-python-agent-all flags, a strict checks on tests dependancies is performed and fails the configure instead of simply disabling the tests. --disable* flags can be used to force tests skipping. Also fixes a minor bug in agent test on enabling event with filtering. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- .gitignore | 1 + configure.ac | 115 ++++++++++++++++++ ..._python_logging => test_python_logging.in} | 29 +++-- 3 files changed, 134 insertions(+), 11 deletions(-) rename tests/regression/ust/python-logging/{test_python_logging => test_python_logging.in} (96%) diff --git a/.gitignore b/.gitignore index 5d24bec18..0ce35f950 100644 --- a/.gitignore +++ b/.gitignore @@ -85,6 +85,7 @@ health_check /tests/regression/ust/fork/fork /tests/regression/ust/fork/fork2 /tests/regression/ust/libc-wrapper/prog +tests/regression/ust/python-logging/test_python_logging /tests/utils/testapp/gen-ust-nevents/gen-ust-nevents /tests/utils/testapp/gen-ust-tracef/gen-ust-tracef /tests/regression/tools/live/live_test diff --git a/configure.ac b/configure.ac index 55977bc27..1cc82c495 100644 --- a/configure.ac +++ b/configure.ac @@ -414,6 +414,104 @@ if test "x$test_java_agent_jul" = "xyes" || test "x$test_java_agent_log4j" = "xy fi fi +# Python agent test +UST_PYTHON_AGENT="lttngust" + +AC_ARG_ENABLE(test-python2-agent, + AS_HELP_STRING([--enable-test-python2-agent], + [enable tests for python2 agent. Python2 interpreter path can be overridden by setting the PYTHON2 environment variable. Default: Autodetect] + ),[:],[test_python2_agent_autodetect=yes] +) + +AC_ARG_ENABLE(test-python3-agent, + AS_HELP_STRING([--enable-test-python3-agent], + [enable tests for python3 agent. Python3 interpreter path can be overridden by setting the PYTHON3 environment variable. Default: Autodetect] + ),[:],[test_python3_agent_autodetect=yes] +) + +AC_ARG_ENABLE(test-python-agent-all, + AS_HELP_STRING([--enable-test-python-agent-all], + [enable test for all python{2/3} agent.] + ), +) + +AS_IF([test ! -z "$enable_test_python_agent_all"], [ + unset test_python2_agent_autodetect + unset test_python3_agent_autodetect +]) + +AS_IF([test "x$enable_test_python_agent_all" = "xyes"], [ + enable_test_python2_agent=yes + enable_test_python3_agent=yes +]) + +AS_IF([test "x$enable_test_python_agent_all" = "xno"], [ + enable_test_python2_agent=no + enable_test_python3_agent=no +]) + + +AS_IF([test "x$enable_test_python2_agent" = "xyes" -o "x$test_python2_agent_autodetect" = "xyes" ], [ + AS_IF([test -z "$PYTHON2"], [ + PYTHON2=python2 + ], [ + AC_MSG_WARN([Using user-defined PYTHON2 ($PYTHON2) for lttng-ust python2 agent check]) + ]) + + AC_PATH_PROG([PYTHON2_BIN],[$PYTHON2]) + AS_IF([test -z "$PYTHON2_BIN"], [ + AS_IF([test -z "$test_python2_agent_autodetect"],[ + AC_MSG_ERROR([No python2 interpreter found. PYTHON2 can be set to override default interpreter path]) + ]) + ], [ + AC_MSG_CHECKING([for python2 lttng-ust agent]) + AS_IF([$PYTHON2_BIN -c "import $UST_PYTHON_AGENT" 2>/dev/null], [ + PYTHON2_AGENT=$PYTHON2_BIN + AC_MSG_RESULT([yes]) + RUN_PYTHON_AGENT_TEST=yes + ], [ + AC_MSG_RESULT([no]) + AS_IF([test -z "$test_python2_agent_autodetect"],[ + AC_MSG_ERROR([No python2 agent found. The path to the agent can be specified by setting the PYTHONPATH environment variable.]) + ]) + ]) + + ]) + +]) + +AS_IF([test "x$enable_test_python3_agent" = "xyes" -o "x$test_python3_agent_autodetect" = "xyes" ], [ + AS_IF([test -z "$PYTHON3"], [ + PYTHON3=python3 + ], [ + AC_MSG_WARN([Using user-defined PYTHON3 ($PYTHON3) for lttng-ust python3 agent check]) + ]) + + AC_PATH_PROG([PYTHON3_BIN],[$PYTHON3]) + AS_IF([test -z "$PYTHON3_BIN"], [ + AS_IF([test -z "$test_python3_agent_autodetect"],[ + AC_MSG_ERROR([No python3 interpreter found. PYTHON3 can be set to override default interpreter path]) + ]) + ], [ + AC_MSG_CHECKING([for python3 lttng-ust agent]) + AS_IF([$PYTHON3_BIN -c "import $UST_PYTHON_AGENT" 2>/dev/null], [ + PYTHON3_AGENT=$PYTHON3_BIN + AC_MSG_RESULT([yes]) + RUN_PYTHON_AGENT_TEST=yes + ], [ + AC_MSG_RESULT([no]) + AS_IF([test -z "$test_python3_agent_autodetect"],[ + AC_MSG_ERROR([No python3 agent found. The path to the agent can be specified by setting the PYTHONPATH environment variable.]) + ]) + ]) + + ]) +]) + +AC_SUBST([RUN_PYTHON_AGENT_TEST]) +AC_SUBST([PYTHON2_AGENT]) +AC_SUBST([PYTHON3_AGENT]) + AC_SYS_LARGEFILE # C compiler tests @@ -549,6 +647,9 @@ AC_CONFIG_FILES([ tests/utils/testapp/gen-ust-tracef/Makefile ]) +# Inject variable into python test script +AC_CONFIG_FILES([tests/regression/ust/python-logging/test_python_logging],[chmod +x tests/regression/ust/python-logging/test_python_logging]) + AC_OUTPUT # @@ -607,6 +708,20 @@ AS_IF([test "x$test_java_agent_log4j" = "xyes"],[ AS_ECHO("Disabled") ]) +AS_ECHO_N("LTTng-UST Python2 agent tests: ") +AS_IF([test ! -z "$PYTHON2_AGENT"],[ + AS_ECHO("Enabled") +],[ + AS_ECHO("Disabled") +]) + +AS_ECHO_N("LTTng-UST Python3 agent tests: ") +AS_IF([test ! -z "$PYTHON3_AGENT"],[ + AS_ECHO("Enabled") +],[ + AS_ECHO("Disabled") +]) + #Python binding enabled/disabled AS_ECHO_N("Python binding: ") AS_IF([test "x${enable_python_binding:-yes}" = xyes], [ diff --git a/tests/regression/ust/python-logging/test_python_logging b/tests/regression/ust/python-logging/test_python_logging.in similarity index 96% rename from tests/regression/ust/python-logging/test_python_logging rename to tests/regression/ust/python-logging/test_python_logging.in index b4fb4104e..8aff4081e 100755 --- a/tests/regression/ust/python-logging/test_python_logging +++ b/tests/regression/ust/python-logging/test_python_logging.in @@ -21,7 +21,7 @@ TEST_DESC="Python support" CURDIR=$(dirname $0)/ TESTDIR=$CURDIR/../../.. NR_ITER=5 -NR_SEC_WAIT=1 +NR_SEC_WAIT=0 TESTAPP_NAME="test" TESTAPP_BIN="$TESTAPP_NAME.py" TESTAPP_PATH="$CURDIR" @@ -30,7 +30,14 @@ EVENT_NAME="python-ev-test1" EVENT_NAME2="python-ev-test2" OUTPUT_DEST="/dev/null" -NUM_TESTS=310 +python_versions=(@PYTHON2_AGENT@ @PYTHON3_AGENT@) +run_test=@RUN_PYTHON_AGENT_TEST@ + +if [[ -z "$run_test" ]]; then + NUM_TESTS=1 +else + NUM_TESTS=$(((154 * ${#python_versions[@]})+2)) +fi source $TESTDIR/utils/utils.sh @@ -72,7 +79,7 @@ function enable_python_filter() local event_name="$2" local filter="$3" - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -p --filter "$filter" >/dev/null 2>&1 + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -p --filter "$filter" >$OUTPUT_DEST ok $? "Enable event $event_name with filter $filter for session $sess_name" } @@ -461,7 +468,7 @@ function test_python_filtering() create_lttng_session_ok $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_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired" [INFO]' + enable_python_filter $SESSION_NAME $EVENT_NAME 'msg == "python-ev-test1 fired [INFO]"' start_lttng_tracing_ok $SESSION_NAME # Run 5 times with a 1 second delay, fire debug and second TP. @@ -557,13 +564,13 @@ plan_tests $NUM_TESTS print_test_banner "$TEST_DESC" -if [ ! -f "$TESTAPP_BIN" ]; then - withapp=0 +if [[ ${#python_versions[@]} -eq 0 || "x$run_test" != "xyes" ]]; then + skip_agent=0 else - withapp=1 + skip_agent=1 fi -skip $withapp "Python support is needed. Skipping all tests." $NUM_TESTS || +skip $skip_agent "Python agent test skipped." $NUM_TESTS || { start_lttng_sessiond @@ -584,20 +591,20 @@ skip $withapp "Python support is needed. Skipping all tests." $NUM_TESTS || test_python_filter_loglevel ) - for python_version in 2 3; + + for python_version in ${python_versions[*]}; do for fct_test in ${tests[@]}; do TRACE_PATH=$(mktemp -d) diag "(Python $python_version)" - ${fct_test} python$python_version + ${fct_test} $python_version if [ $? -ne 0 ]; then break; fi rm -rf $TRACE_PATH done done - stop_lttng_sessiond } -- 2.34.1