Add condition-targeting error query
[lttng-tools.git] / tests / regression / ust / python-logging / test_python_logging.in
index 2b5852c2f77b1d91b6623e649a752431d26c55af..470452260eb49132258425ab7a914e62bbe6f58f 100755 (executable)
@@ -1,20 +1,9 @@
 #!/bin/bash
 #
-# Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
-# Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
+# Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
+# Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
 #
-# This program is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License, version 2 only, as published by
-# the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 51
-# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# SPDX-License-Identifier: GPL-2.0-only
 
 TEST_DESC="Python support"
 
@@ -22,9 +11,9 @@ CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../../..
 NR_ITER=5
 NR_SEC_WAIT=0
-TESTAPP_NAME="test"
+TESTAPP_NAME="gen-py-events"
 TESTAPP_BIN="$TESTAPP_NAME.py"
-TESTAPP_PATH="@abs_top_srcdir@/tests/regression/ust/python-logging"
+TESTAPP_PATH="$TESTDIR/utils/testapp/$TESTAPP_NAME/"
 SESSION_NAME="python-test"
 EVENT_NAME="python-ev-test1"
 EVENT_NAME2="python-ev-test2"
@@ -36,7 +25,7 @@ run_test=@RUN_PYTHON_AGENT_TEST@
 if [[ -z "$run_test" ]]; then
        NUM_TESTS=1
 else
-       NUM_TESTS=$(((194 * ${#python_versions[@]})+2))
+       NUM_TESTS=$(((199 * ${#python_versions[@]})+2))
 fi
 
 source $TESTDIR/utils/utils.sh
@@ -66,9 +55,7 @@ function run_app
                opt="${opt} -g ${go_file}"
        fi
 
-       set -x
        $python $TESTAPP_PATH/$TESTAPP_BIN -n $NR_ITER -s $NR_SEC_WAIT $opt
-       set +x
 }
 
 function run_app_background
@@ -119,8 +106,8 @@ function enable_python_filter_loglevel_only()
 
 function test_python_before_start ()
 {
-       local ready_file=$(mktemp -u)
-       local go_file=$(mktemp -u)
+       local ready_file=$(mktemp --tmpdir -u)
+       local go_file=$(mktemp --tmpdir -u)
 
        diag "Test Python application BEFORE tracing starts"
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
@@ -698,6 +685,35 @@ function test_python_filter_loglevel()
        fi
 }
 
+function test_python_trigger_notify_action
+{
+       uid=$(id --user)
+       tmp_expected_stdout=$(mktemp --tmpdir -t test_list_triggers_python_cli_expected_stdout.XXXXXX)
+
+       diag "Test Python trigger with notify action"
+
+       lttng_add_trigger_ok "my_python_trigger" \
+               --condition event-rule-matches --type=python --action notify
+
+       cat > "${tmp_expected_stdout}" <<- EOF
+       - name: my_python_trigger
+         owner uid: ${uid}
+         condition: event rule matches
+           rule: * (type: python:logging)
+           errors: none
+         actions:
+           notify
+             errors: none
+         errors: none
+       EOF
+
+       list_triggers_matches_ok "Python trigger listing" "${tmp_expected_stdout}"
+
+       lttng_remove_trigger_ok "my_python_trigger"
+
+       rm -f "${tmp_expected_stdout}"
+}
+
 plan_tests $NUM_TESTS
 
 print_test_banner "$TEST_DESC"
@@ -730,6 +746,7 @@ skip $skip_agent "Python agent test skipped." $NUM_TESTS ||
                test_python_after_start
                test_python_multi_session
                test_python_filter_loglevel
+               test_python_trigger_notify_action
        )
 
 
@@ -737,7 +754,7 @@ skip $skip_agent "Python agent test skipped." $NUM_TESTS ||
        do
                for fct_test in ${tests[@]};
                do
-                       TRACE_PATH=$(mktemp -d)
+                       TRACE_PATH=$(mktemp --tmpdir -d tmp.test_python_logging_trace_path.XXXXXX)
 
                        diag "(Python $python_version)"
                        ${fct_test} $python_version
This page took 0.026377 seconds and 4 git commands to generate.