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