Tests: Convert the tools filtering tests output to TAP
[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_TESTS=46
28 source $TESTDIR/utils/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 enable_cmd="$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event"
39 $enable_cmd $event_name -s $sess_name -u --filter "$filter" 2> $ENABLE_EVENT_STDERR 1> /dev/null
40
41 # Enable must fail
42 if [ $? -eq 0 ]; then
43 fail "Enable lttng event with filtering and unsupported operator"
44 return 1
45 else
46 pass "Enable lttng event with filtering and unsupported operator"
47 return 0
48 fi
49 }
50
51 function test_unsupported_op
52 {
53 test_op_str=$1
54 test_op_tkn=$2
55
56 diag "Test filter expression with unsupported operator $test_op_str ($test_op_tkn)"
57
58 # Create session
59 create_lttng_session $SESSION_NAME $TRACE_PATH
60
61 # Create filter
62 if [ "$test_op_str" == "UNARY_BIN_NOT" ]; then
63 TEST_FILTER="${test_op_tkn}1"
64 else
65 TEST_FILTER="intfield $test_op_tkn 1"
66 fi
67
68 # Apply filter
69 enable_ust_lttng_event_filter_unsupported $SESSION_NAME $EVENT_NAME "$TEST_FILTER"
70
71 # Test stderr for unsupported operator
72
73 grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR
74
75 if [ $? -eq 1 ]; then
76 fail "Unsupported operator test $test_op_str ($test_op_tkn)"
77 return 1
78 else
79 pass "Unsupported operator test $test_op_str ($test_op_tkn)"
80 fi
81
82 # Destroy session
83 destroy_lttng_session $SESSION_NAME
84 return 0
85 }
86
87 plan_tests $NUM_TESTS
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
This page took 0.0315 seconds and 4 git commands to generate.