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)
30 NUM_TESTS
=$
(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
32 source $TESTDIR/utils
/utils.sh
34 function enable_lttng_event_filter
41 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
$event_name -s $sess_name \
42 $domain --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev
/null
46 fail
"Enable lttng event with filtering and invalid filter"
49 pass
"Enable lttng event with filtering and invalid filter"
54 function test_invalid_filter
57 test_invalid_filter
="$2"
59 diag
"Test filter expression with invalid filter"
60 diag
"Filter: $test_invalid_filter"
63 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
66 enable_lttng_event_filter
$domain $SESSION_NAME $EVENT_NAME "$test_invalid_filter"
69 destroy_lttng_session_ok
$SESSION_NAME
72 function test_bytecode_limit
76 # Current bytecode limitation is 65536 bytes long.
77 # Generate a huge bytecode with some perl-fu
78 BYTECODE_LIMIT
=`perl -e 'print "intfield" . " && 1" x5460'`
80 diag
"Test filter bytecode limits (64KiB)"
83 create_lttng_session_ok
$SESSION_NAME $TRACE_PATH
86 enable_lttng_event_filter
$domain $SESSION_NAME $EVENT_NAME "$BYTECODE_LIMIT"
89 destroy_lttng_session_ok
$SESSION_NAME
94 print_test_banner
"$TEST_DESC"
111 "asdfas
< 2332 || asdf
+ 1 > 1"
112 "!+-+++-------+++++++++++-----!!--!44+1"
113 "aaa||
(gg
)+(333----1)"
115 # Unmatched parenthesis
116 "((((((((((((((intfield
)))))))))))))"
117 '0 || ("abc
" != "def
")) && (3 < 4)'
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
\""
135 # Only \$ctx is supported for now
136 "\
$global.value
== 0"
137 "0 == \
$global.value
"
138 # Cannot compare two full star globbing patterns
139 '"hello
*world
" == "yes*man
"'
140 '"hello
*world
" == "yesman
*"'
141 '"helloworld
*" == "yes*man
"'
142 # May only use != and == operators when one of them is a full
143 # star globbing pattern
144 '"hello
*world
" < field'
145 '"hello
*world
" <= field'
146 '"hello
*world
" >= field'
147 '"hello
*world
" > field'
148 '"hello
*world
" || field'
149 '"hello
*world
" && field'
150 'field < "hello
*world
"'
151 'field <= "hello
*world
"'
152 'field >= "hello
*world
"'
153 'field > "hello
*world
"'
154 'field && "hello
*world
"'
155 'field || "hello
*world
"'
160 diag "Test UST filters
"
163 while [ "$i" -lt "${#INVALID_FILTERS[@]}" ]; do
164 echo "${INVALID_FILTERS[$i]}"
165 test_invalid_filter -u "${INVALID_FILTERS[$i]}"
169 test_bytecode_limit -u
171 if [ "$
(id
-u)" == "0" ]; then
177 skip $isroot "Root access is needed. Skipping all kernel invalid filter tests.
" $NUM_KERNEL_TESTS ||
179 diag "Test kernel filters
"
181 while [ "$i" -lt "${#INVALID_FILTERS[@]}" ]; do
182 echo "${INVALID_FILTERS[$i]}"
183 test_invalid_filter -k "${INVALID_FILTERS[$i]}"
187 test_bytecode_limit -k
191 rm -f $ENABLE_EVENT_STDERR