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