X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fwildcard%2Ftest_event_wildcard;h=0bf2d2c2c1bf56aae11db4add11891ff2e3979c9;hp=b487961c657a188adec8dbae80ad9317c440bd2d;hb=5bbf6fde94060f0dd7952e8595dcf6f05c61ad2a;hpb=f34b33a2d05bec32cf8c2d057fe16bd91125db90 diff --git a/tests/regression/tools/wildcard/test_event_wildcard b/tests/regression/tools/wildcard/test_event_wildcard index b487961c6..0bf2d2c2c 100755 --- a/tests/regression/tools/wildcard/test_event_wildcard +++ b/tests/regression/tools/wildcard/test_event_wildcard @@ -1,52 +1,58 @@ #!/bin/bash # -# Copyright (C) - 2013 Christian Babeux -# Copyright (C) - 2015 Mathieu Desnoyers +# Copyright (C) 2013 Christian Babeux +# Copyright (C) 2015 Mathieu Desnoyers # -# 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="UST tracer - Event wildcard" +TEST_DESC="LTTng - Event wildcard test" CURDIR=$(dirname $0)/ TESTDIR=$CURDIR/../../.. -LTTNG_BIN="lttng" TESTAPP_PATH="$TESTDIR/utils/testapp" TESTAPP_NAME="gen-ust-events" TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" SESSION_NAME="wildcard" -EVENT_NAME="tp:tptest" -NUM_TESTS=39 NR_ITER=100 +NR_USEC_WAIT=1 +NUM_GLOBAL_TESTS=2 +NUM_UST_TESTS=$(( 7 * 25 )) +NUM_KERNEL_TESTS=$(( 7 * 25 )) +NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS)) source $TESTDIR/utils/utils.sh -if [ ! -x "$TESTAPP_BIN" ]; then - BAIL_OUT "No UST nevents binary detected." -fi +function run_ust +{ + $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT +} + +function run_kernel +{ + # Trigger the event for 100 iterations + echo -n "100" > /proc/lttng-test-filter-event +} function test_event_wildcard() { TRACE_PATH=$(mktemp -d) - FIND="${1}" - WILDCARD="${2}" + DOMAIN="$1" + FIND="$2" + WILDCARD="$3" + CHANNEL='' create_lttng_session_ok $SESSION_NAME $TRACE_PATH - enable_ust_lttng_event_ok $SESSION_NAME "$WILDCARD" + + if [ $DOMAIN = kernel ]; then + CHANNEL=chan + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -k chan -s $SESSION_NAME --subbuf-size=8M --num-subbuf=4 + fi + + enable_${DOMAIN}_lttng_event_ok $SESSION_NAME "$WILDCARD" "$CHANNEL" start_lttng_tracing_ok - $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT + run_${DOMAIN} ok $? "Traced application stopped." stop_lttng_tracing_ok @@ -55,7 +61,7 @@ function test_event_wildcard() if [ ${FIND} -eq 1 ]; then trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH else - validate_trace_empty $TRACE_PATH + trace_matches $EVENT_NAME 0 $TRACE_PATH fi rm -rf $TRACE_PATH @@ -64,16 +70,16 @@ function test_event_wildcard() function test_event_wildcard_fail() { TRACE_PATH=$(mktemp -d) - WILDCARD="${1}" + DOMAIN="$1" + WILDCARD="$2" create_lttng_session_ok $SESSION_NAME $TRACE_PATH - enable_ust_lttng_event_fail $SESSION_NAME "$WILDCARD" + enable_${DOMAIN}_lttng_event_fail $SESSION_NAME "$WILDCARD" destroy_lttng_session_ok $SESSION_NAME rm -rf $TRACE_PATH } - # MUST set TESTDIR before calling those functions plan_tests $NUM_TESTS @@ -81,13 +87,87 @@ print_test_banner "$TEST_DESC" start_lttng_sessiond -test_event_wildcard 1 'tp:tp*' -test_event_wildcard 1 '*' -test_event_wildcard 1 'tp:tptest*' -test_event_wildcard 0 'tp:abc*' +diag "Test UST wildcard" + +if [ ! -x "$TESTAPP_BIN" ]; then + BAIL_OUT "No UST nevents binary detected." +fi + +EVENT_NAME="tp:tptest" + +# non-matching +test_event_wildcard ust 0 'tp:abc*' +test_event_wildcard ust 0 '*abc' +test_event_wildcard ust 0 '*z*' +test_event_wildcard ust 0 '*\**' +test_event_wildcard ust 0 '*\*' +test_event_wildcard ust 0 '\**' +test_event_wildcard ust 0 '*:*tpte*s' +test_event_wildcard ust 0 'tp**tpTest' + +# matching +test_event_wildcard ust 1 'tp:tp*' +test_event_wildcard ust 1 '*' +test_event_wildcard ust 1 'tp:tptest*' +test_event_wildcard ust 1 '**' +test_event_wildcard ust 1 '***' +test_event_wildcard ust 1 '*tptest' +test_event_wildcard ust 1 '**tptest' +test_event_wildcard ust 1 '*tpte*' +test_event_wildcard ust 1 '*tp*' +test_event_wildcard ust 1 '*tp**' +test_event_wildcard ust 1 '*:*tptest' +test_event_wildcard ust 1 '*:*tpte*t' +test_event_wildcard ust 1 't*p*:*t*e*s*t' +test_event_wildcard ust 1 '*t*p*:*t*e*s*t*' +test_event_wildcard ust 1 'tp*tptest' +test_event_wildcard ust 1 'tp**tptest' +test_event_wildcard ust 1 'tp*test' + +if [ "$(id -u)" == "0" ]; then + isroot=1 +else + isroot=0 +fi -test_event_wildcard_fail 'tp:*tp' -test_event_wildcard_fail 'tp:tp**' -test_event_wildcard_fail '*tp:tp*' +skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS || +{ + diag "Test kernel wildcards" + + modprobe lttng-test + + EVENT_NAME="lttng_test_filter_event" + + # non-matching + test_event_wildcard kernel 0 'lttng_test_abc*' + test_event_wildcard kernel 0 '*abc' + test_event_wildcard kernel 0 '*z*' + test_event_wildcard kernel 0 '*\**' + test_event_wildcard kernel 0 '*\*' + test_event_wildcard kernel 0 '\**' + test_event_wildcard kernel 0 '*:*eve*n' + + # matching + test_event_wildcard kernel 1 'lttng_test_fil*' + test_event_wildcard kernel 1 '*' + test_event_wildcard kernel 1 'lttng_test_filter_event*' + test_event_wildcard kernel 1 '**' + test_event_wildcard kernel 1 '***' + test_event_wildcard kernel 1 '*filter_event' + test_event_wildcard kernel 1 '*ter_ev*' + test_event_wildcard kernel 1 '*test*' + test_event_wildcard kernel 1 '*test**' + test_event_wildcard kernel 1 '*e*' + test_event_wildcard kernel 1 '*_*event' + test_event_wildcard kernel 1 '*_*filter_*nt' + test_event_wildcard kernel 1 '*_**filter_*nt' + test_event_wildcard kernel 1 'l*t*t*n*g*_*t*e*s*t*_*f*i*l*t*e*r*_*e*v*e*n*t' + test_event_wildcard kernel 1 '*l*t*t*n*g*_*t*e*s*t*_*f*i*l*t*e*r*_*e*v*e*n*t*' + test_event_wildcard kernel 1 'lttng*event' + test_event_wildcard kernel 1 'lttng*test*filter*event' + test_event_wildcard kernel 1 '*lttng*test*filter*event*' + + rmmod lttng-test +} stop_lttng_sessiond