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 | 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) | |
03276eea | 27 | NUM_TESTS=46 |
9ac429ef | 28 | source $TESTDIR/utils/utils.sh |
5ed358a4 | 29 | |
5ed358a4 CB |
30 | function enable_ust_lttng_event_filter_unsupported |
31 | { | |
32 | sess_name=$1 | |
33 | event_name=$2 | |
34 | filter=$3 | |
35 | ||
5ed358a4 CB |
36 | enable_cmd="$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event" |
37 | $enable_cmd $event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null | |
38 | ||
39 | # Enable must fail | |
40 | if [ $? -eq 0 ]; then | |
03276eea | 41 | fail "Enable lttng event with filtering and unsupported operator" |
5ed358a4 CB |
42 | return 1 |
43 | else | |
03276eea | 44 | pass "Enable lttng event with filtering and unsupported operator" |
5ed358a4 CB |
45 | return 0 |
46 | fi | |
47 | } | |
48 | ||
49 | function test_unsupported_op | |
50 | { | |
51 | test_op_str=$1 | |
52 | test_op_tkn=$2 | |
53 | ||
03276eea | 54 | diag "Test filter expression with unsupported operator $test_op_str ($test_op_tkn)" |
5ed358a4 CB |
55 | |
56 | # Create session | |
bf6ae429 | 57 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
5ed358a4 CB |
58 | |
59 | # Create filter | |
60 | if [ "$test_op_str" == "UNARY_BIN_NOT" ]; then | |
61 | TEST_FILTER="${test_op_tkn}1" | |
62 | else | |
63 | TEST_FILTER="intfield $test_op_tkn 1" | |
64 | fi | |
65 | ||
66 | # Apply filter | |
67 | enable_ust_lttng_event_filter_unsupported $SESSION_NAME $EVENT_NAME "$TEST_FILTER" | |
68 | ||
69 | # Test stderr for unsupported operator | |
03276eea | 70 | |
5ed358a4 CB |
71 | grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR |
72 | ||
73 | if [ $? -eq 1 ]; then | |
03276eea | 74 | fail "Unsupported operator test $test_op_str ($test_op_tkn)" |
5ed358a4 CB |
75 | return 1 |
76 | else | |
03276eea | 77 | pass "Unsupported operator test $test_op_str ($test_op_tkn)" |
5ed358a4 CB |
78 | fi |
79 | ||
80 | # Destroy session | |
67b4c664 | 81 | destroy_lttng_session_ok $SESSION_NAME |
5ed358a4 CB |
82 | return 0 |
83 | } | |
84 | ||
03276eea CB |
85 | plan_tests $NUM_TESTS |
86 | ||
e3bef725 CB |
87 | print_test_banner "$TEST_DESC" |
88 | ||
5ed358a4 CB |
89 | # Unsupported operators |
90 | OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT" | |
91 | "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT") | |
92 | ||
93 | OP_TKN=("*" "/" "%" "+" "-" "<<" ">>" "&" "|" "^" "~") | |
94 | ||
95 | OP_COUNT=${#OP_STR[@]} | |
96 | i=0 | |
97 | ||
98 | start_lttng_sessiond | |
99 | ||
100 | while [ "$i" -lt "$OP_COUNT" ]; do | |
101 | test_unsupported_op "${OP_STR[$i]}" "${OP_TKN[$i]}" | |
102 | ||
103 | if [ $? -eq 1 ]; then | |
104 | exit 1 | |
105 | fi | |
106 | ||
107 | let "i++" | |
108 | done | |
109 | ||
110 | stop_lttng_sessiond | |
111 | ||
112 | # Cleanup | |
113 | rm -f $ENABLE_EVENT_STDERR | |
114 | rm -rf $TRACE_PATH |