Fix: filter tests now accept "." in identifiers
[lttng-tools.git] / tests / regression / tools / filtering / test_unsupported_op
1 #!/bin/bash
2 #
3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4 #
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.
8 #
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
12 # more details.
13 #
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.
17
18 TEST_DESC="Filtering - Unsupported operators"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../..
22 LTTNG_BIN="lttng"
23 SESSION_NAME="filter-unsupported-ops"
24 EVENT_NAME="bogus"
25 ENABLE_EVENT_STDERR="/tmp/unsupported-ops-enable"
26 TRACE_PATH=$(mktemp -d)
27 NUM_GLOBAL_TESTS=2
28 NUM_UST_TESTS=44
29 NUM_KERNEL_TESTS=44
30 NUM_TESTS=$(($NUM_UST_TESTS+$NUM_KERNEL_TESTS+$NUM_GLOBAL_TESTS))
31
32 source $TESTDIR/utils/utils.sh
33
34 function enable_lttng_event_filter_unsupported
35 {
36 domain="$1"
37 sess_name="$2"
38 event_name="$3"
39 filter="$4"
40
41 enable_cmd="$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event"
42 $enable_cmd $event_name -s $sess_name $domain --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null
43
44 # Enable must fail
45 if [ $? -eq 0 ]; then
46 fail "Enable lttng event with filtering and unsupported operator"
47 return 1
48 else
49 pass "Enable lttng event with filtering and unsupported operator"
50 return 0
51 fi
52 }
53
54 function test_unsupported_op
55 {
56 domain="$1"
57 test_op_str="$2"
58 test_op_tkn="$3"
59
60 diag "Test filter expression with unsupported operator $test_op_str ($test_op_tkn)"
61
62 # Create session
63 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
64
65 # Create filter
66 if [ "$test_op_str" == "UNARY_BIN_NOT" ]; then
67 TEST_FILTER="${test_op_tkn}1"
68 else
69 TEST_FILTER="intfield $test_op_tkn 1"
70 fi
71
72 # Apply filter
73 enable_lttng_event_filter_unsupported $domain $SESSION_NAME $EVENT_NAME "$TEST_FILTER"
74
75 # Test stderr for unsupported operator
76
77 grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR
78
79 if [ $? -eq 1 ]; then
80 fail "Unsupported operator test $test_op_str ($test_op_tkn)"
81 return 1
82 else
83 pass "Unsupported operator test $test_op_str ($test_op_tkn)"
84 fi
85
86 # Destroy session
87 destroy_lttng_session_ok $SESSION_NAME
88 return 0
89 }
90
91 plan_tests $NUM_TESTS
92
93 print_test_banner "$TEST_DESC"
94
95 # Unsupported operators
96 OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT"
97 "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT")
98
99 OP_TKN=("*" "/" "%" "+" "-" "<<" ">>" "&" "|" "^" "~")
100
101 OP_COUNT=${#OP_STR[@]}
102
103 start_lttng_sessiond
104
105 diag "Test UST unsupported filter operations"
106
107 i=0
108 while [ "$i" -lt "$OP_COUNT" ]; do
109 test_unsupported_op -u "${OP_STR[$i]}" "${OP_TKN[$i]}"
110
111 if [ $? -eq 1 ]; then
112 exit 1
113 fi
114
115 let "i++"
116 done
117
118 if [ "$(id -u)" == "0" ]; then
119 isroot=1
120 else
121 isroot=0
122 fi
123
124 skip $isroot "Root access is needed. Skipping all kernel unsupported filter operations tests." $NUM_KERNEL_TESTS ||
125 {
126 diag "Test kernel unsupported filter operations"
127
128 i=0
129 while [ "$i" -lt "$OP_COUNT" ]; do
130 test_unsupported_op -k "${OP_STR[$i]}" "${OP_TKN[$i]}"
131
132 if [ $? -eq 1 ]; then
133 exit 1
134 fi
135
136 let "i++"
137 done
138 }
139
140 stop_lttng_sessiond
141
142 # Cleanup
143 rm -f $ENABLE_EVENT_STDERR
144 rm -rf $TRACE_PATH
This page took 0.03235 seconds and 4 git commands to generate.