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)/ | |
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 | ||
28 | source $TESTDIR/utils.sh | |
29 | ||
30 | print_test_banner "$TEST_DESC" | |
31 | ||
32 | function enable_ust_lttng_event_filter_unsupported | |
33 | { | |
34 | sess_name=$1 | |
35 | event_name=$2 | |
36 | filter=$3 | |
37 | ||
38 | echo -n "Enabling lttng event with filtering and unsupported operator " | |
39 | enable_cmd="$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event" | |
40 | $enable_cmd $event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null | |
41 | ||
42 | # Enable must fail | |
43 | if [ $? -eq 0 ]; then | |
44 | print_fail | |
45 | return 1 | |
46 | else | |
47 | print_ok | |
48 | return 0 | |
49 | fi | |
50 | } | |
51 | ||
52 | function test_unsupported_op | |
53 | { | |
54 | test_op_str=$1 | |
55 | test_op_tkn=$2 | |
56 | ||
57 | echo "" | |
58 | echo -e "=== Testing filter expression with unsupported operator $test_op_str ($test_op_tkn)" | |
59 | ||
60 | # Create session | |
61 | create_lttng_session $SESSION_NAME $TRACE_PATH | |
62 | ||
63 | # Create filter | |
64 | if [ "$test_op_str" == "UNARY_BIN_NOT" ]; then | |
65 | TEST_FILTER="${test_op_tkn}1" | |
66 | else | |
67 | TEST_FILTER="intfield $test_op_tkn 1" | |
68 | fi | |
69 | ||
70 | # Apply filter | |
71 | enable_ust_lttng_event_filter_unsupported $SESSION_NAME $EVENT_NAME "$TEST_FILTER" | |
72 | ||
73 | # Test stderr for unsupported operator | |
74 | echo -n "Unsupported operator test $test_op_str ($test_op_tkn) " | |
75 | grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR | |
76 | ||
77 | if [ $? -eq 1 ]; then | |
78 | print_fail | |
79 | return 1 | |
80 | else | |
81 | print_ok | |
82 | fi | |
83 | ||
84 | # Destroy session | |
85 | destroy_lttng_session $SESSION_NAME | |
86 | return 0 | |
87 | } | |
88 | ||
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 |