.gitignore: ignore local vscode workspace settings file
[lttng-tools.git] / tests / regression / tools / filtering / test_valid_filter
index 319204ccf7b4a0549ad5a866f768eae1ecde7972..79a9d85f237c393317e9df6da9ae369aeb3a29d0 100755 (executable)
@@ -1,31 +1,21 @@
 #!/bin/bash
 #
-# Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
+# Copyright (C) 2012 Christian Babeux <christian.babeux@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.
+# SPDX-License-Identifier: GPL-2.0-only
 #
-# 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.
 
 TEST_DESC="Filtering - Valid filters"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../../..
-LTTNG_BIN="lttng"
-STATS_BIN="$TESTDIR/utils/babelstats.pl"
+BT2_PLUGINS_DIR="${TESTDIR}/utils/bt2_plugins"
+
 SESSION_NAME="valid_filter"
 NR_ITER=100
 NUM_GLOBAL_TESTS=2
-NUM_UST_TESTS=1074
-NUM_KERNEL_TESTS=1008
+NUM_UST_TESTS=1122
+NUM_KERNEL_TESTS=1056
 NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
 
 source $TESTDIR/utils/utils.sh
@@ -105,11 +95,10 @@ function test_valid_filter
        event_name="$3"
        filter="$4"
        validator="$5"
+       local trace_path=$(mktemp -d -t tmp.test_filtering_valid_filters_trace_path.XXXXXX)
 
        diag "Test valid $domain_name filter: $filter"
 
-       trace_path=$(mktemp -d)
-
        # Create session
        create_lttng_session_ok $SESSION_NAME $trace_path
 
@@ -122,16 +111,12 @@ function test_valid_filter
        stop_lttng_tracing_ok $SESSION_NAME
 
        # Destroy session
-       destroy_lttng_session_ok $SESSION_NAME
+       destroy_lttng_session_ok $SESSION_NAME --no-wait
 
-       stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name`
-
-       rm -rf $trace_path
+       stats=$("${BABELTRACE_BIN}" --plugin-path "${BT2_PLUGINS_DIR}" "${trace_path}" -c filter.lttngtest.event_name -p "names=[\"${event_name}\"]" -c sink.lttngtest.field_stats)
 
        $validator "$stats"
-
        ok $? "Validate trace filter output"
-
        rm -rf $trace_path
 }
 
@@ -413,6 +398,8 @@ plan_tests $NUM_TESTS
 
 print_test_banner "$TEST_DESC"
 
+bail_out_if_no_babeltrace
+
 issue_356_filter="intfield > 0 && intfield > 1 && "
 issue_356_filter+="intfield > 2 && intfield > 3 && "
 issue_356_filter+="intfield > 4 && intfield > 5 && "
@@ -706,11 +693,29 @@ UST_FILTERS=(
        true_statement
        "-1==~0"
 
-       true_statement
-       "1<<1==2"       # C99 operator priority: comparator before bitwise
+       true_statement  # unsigned bitwise ops
+       "~0>>4==0x0fffffffffffffff"
+
+       has_no_event
+       "1<<-1"
 
        has_no_event
-       "!(1<<1==2)"    # C99 operator priority: comparator before bitwise
+       "1<<10000"
+
+       true_statement  # comparator is signed, shift is unsigned
+       "(1<<63) < 0"
+
+       true_statement
+       "(1<<2!=4)==0"  # operator priority: shift before equality
+
+       true_statement
+       "1&3==1"        # operator priority: masks before equality
+
+       true_statement
+       "(3|1==3)==1"   # operator priority: masks before equality
+
+       true_statement
+       "(2^1==3)==1"   # operator priority: masks before equality
 
        true_statement
        "(1 << 32) == 4294967296"
@@ -826,6 +831,16 @@ UST_FILTERS=(
        has_no_event
        "0 == \$ctx.vtid.blah"
 
+       # check that bytecode linker refuses to link against a
+       # non-string array.
+       has_no_event
+       'arrfield1 != "dontmatch"'
+
+       # check that bytecode linker refuses to link against a
+       # non-string sequence.
+       has_no_event
+       'seqfield1 != "dontmatch"'
+
        END
 )
 
@@ -1167,11 +1182,29 @@ KERNEL_FILTERS=(
        true_statement
        "-1==~0"
 
-       true_statement
-       "1<<1==2"       # C99 operator priority: comparator before bitwise
+       true_statement  # unsigned bitwise ops
+       "~0>>4==0x0fffffffffffffff"
+
+       has_no_event
+       "1<<-1"
 
        has_no_event
-       "!(1<<1==2)"    # C99 operator priority: comparator before bitwise
+       "1<<10000"
+
+       true_statement  # comparator is signed, shift is unsigned
+       "(1<<63) < 0"
+
+       true_statement
+       "(1<<2!=4)==0"  # operator priority: shift before equality
+
+       true_statement
+       "1&3==1"        # operator priority: masks before equality
+
+       true_statement
+       "(3|1==3)==1"   # operator priority: masks before equality
+
+       true_statement
+       "(2^1==3)==1"   # operator priority: masks before equality
 
        true_statement
        "(1 << 32) == 4294967296"
@@ -1401,6 +1434,16 @@ KERNEL_FILTERS=(
        has_no_event
        'stringfield == "test\*"'
 
+       # check that bytecode linker refuses to link against a
+       # non-string array.
+       has_no_event
+       'arrfield1 != "dontmatch"'
+
+       # check that bytecode linker refuses to link against a
+       # non-string sequence.
+       has_no_event
+       'seqfield1 != "dontmatch"'
+
        ${KIRK_KRAUSS_TESTS[@]}
 
        END
@@ -1408,13 +1451,7 @@ KERNEL_FILTERS=(
 
 IFS=$OLDIFS
 
-if [ "$(id -u)" == "0" ]; then
-       isroot=1
-else
-       isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel valid filter tests." $NUM_KERNEL_TESTS ||
+check_skip_kernel_test "$NUM_KERNEL_TESTS" "Skipping kernel valid filter tests." ||
 {
        diag "Test kernel valid filters"
 
@@ -1440,7 +1477,7 @@ skip $isroot "Root access is needed. Skipping all kernel valid filter tests." $N
                i=$(( i + 2 ))
        done
 
-       rmmod lttng-test
+       modprobe --remove lttng-test
 }
 
 stop_lttng_sessiond
This page took 0.026691 seconds and 4 git commands to generate.