3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License, version 2 only, as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 TEST_DESC
="Filtering - Invalid filters"
23 SESSION_NAME
="filter-invalid"
25 ENABLE_EVENT_STDERR
="/tmp/invalid-filters-stderr"
26 TRACE_PATH
=$
(mktemp
-d)
28 source $TESTDIR/utils.sh
30 print_test_banner
"$TEST_DESC"
32 function enable_ust_lttng_event_filter
37 echo -n "Enabling lttng event with filtering and invalid filter "
39 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev
/null
51 function test_invalid_filter
53 test_invalid_filter
="$1"
56 echo -e "=== Testing filter expression with invalid filter"
57 echo -e "Filter: $test_invalid_filter"
60 create_lttng_session
$SESSION_NAME $TRACE_PATH
63 enable_ust_lttng_event_filter
$SESSION_NAME $EVENT_NAME "$test_invalid_filter"
66 destroy_lttng_session
$SESSION_NAME
69 function test_bytecode_limit
71 # Current bytecode limitation is 65536 bytes long.
72 # Generate a huge bytecode with some perl-fu
73 BYTECODE_LIMIT
=`perl -e 'print "intfield" . " && 1" x5460'`
76 echo -e "=== Testing filter bytecode limits (64KiB)"
79 create_lttng_session
$SESSION_NAME $TRACE_PATH
82 enable_ust_lttng_event_filter
$SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT"
85 destroy_lttng_session
$SESSION_NAME
105 "asdfas
< 2332 || asdf
+ 1 > 1"
106 "!+-+++-------+++++++++++-----!!--!44+1"
107 "aaa||
(gg
)+(333----1)"
109 # Unmatched parenthesis
110 "((((((((((((((intfield
)))))))))))))"
111 '0 || ("abc
" != "def
")) && (3 < 4)'
113 "a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a
"
119 "asdf.asdfsd.sadf
< 4"
120 "asdfasdf-
>asdfasdf
< 2"
121 # String can't be root node
123 # Unary op on string not allowed
125 # Comparison with string type not allowed
126 "\"somestring
\" > 42"
127 "\"somestring
\" > 42.0"
128 "42 > \"somestring
\""
129 "42.0 > \"somestring
\""
130 # Logical operator with string type not allowed
131 "\"somestring
\" ||
1"
132 "1 ||
\"somestring
\""
133 # Nesting of binary operator not allowed
139 for FILTER in ${INVALID_FILTERS[@]};
141 test_invalid_filter "$FILTER"
149 rm -f $ENABLE_EVENT_STDERR