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"
21 TESTDIR
=$CURDIR/..
/..
/..
23 SESSION_NAME
="filter-invalid"
25 ENABLE_EVENT_STDERR
="/tmp/invalid-filters-stderr"
26 TRACE_PATH
=$
(mktemp
-d)
29 source $TESTDIR/utils
/utils.sh
31 function enable_ust_lttng_event_filter
37 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev
/null
41 fail
"Enable lttng event with filtering and invalid filter"
44 pass
"Enable lttng event with filtering and invalid filter"
49 function test_invalid_filter
51 test_invalid_filter
="$1"
53 diag
"Test filter expression with invalid filter"
54 diag
"Filter: $test_invalid_filter"
57 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
60 enable_ust_lttng_event_filter
$SESSION_NAME $EVENT_NAME "$test_invalid_filter"
63 destroy_lttng_session_ok
$SESSION_NAME
66 function test_bytecode_limit
68 # Current bytecode limitation is 65536 bytes long.
69 # Generate a huge bytecode with some perl-fu
70 BYTECODE_LIMIT
=`perl -e 'print "intfield" . " && 1" x5460'`
72 diag
"Test filter bytecode limits (64KiB)"
75 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
78 enable_ust_lttng_event_filter
$SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT"
81 destroy_lttng_session_ok
$SESSION_NAME
86 print_test_banner
"$TEST_DESC"
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
136 # Exactly one chaining level under \$ctx allowed
137 "\
$ctx.vtid.blah
== 0"
138 "0 == \
$ctx.vtid.blah
"
143 # Only \$ctx is supported for now
144 "\
$global.value
== 0"
145 "0 == \
$global.value
"
146 # A wildcard should only appear as the last character in a string literal
147 "msg
== \"my_event
*_blah
\""
151 for FILTER in ${INVALID_FILTERS[@]};
153 test_invalid_filter "$FILTER"
161 rm -f $ENABLE_EVENT_STDERR