Fix: filter tests now accept "." in identifiers
[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
MD
27NUM_GLOBAL_TESTS=2
28NUM_UST_TESTS=44
29NUM_KERNEL_TESTS=44
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
CB
95# Unsupported operators
96OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT"
97 "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT")
98
99OP_TKN=("*" "/" "%" "+" "-" "<<" ">>" "&" "|" "^" "~")
100
101OP_COUNT=${#OP_STR[@]}
5ed358a4
CB
102
103start_lttng_sessiond
104
f6788fc4
MD
105diag "Test UST unsupported filter operations"
106
107i=0
5ed358a4 108while [ "$i" -lt "$OP_COUNT" ]; do
f6788fc4 109 test_unsupported_op -u "${OP_STR[$i]}" "${OP_TKN[$i]}"
5ed358a4
CB
110
111 if [ $? -eq 1 ]; then
112 exit 1
113 fi
114
115 let "i++"
116done
117
f6788fc4
MD
118if [ "$(id -u)" == "0" ]; then
119 isroot=1
120else
121 isroot=0
122fi
123
124skip $isroot "Root access is needed. Skipping all kernel unsupported filter operations tests." $NUM_KERNEL_TESTS ||
125{
126 diag "Test kernel unsupported filter operations"
127
128 i=0
129 while [ "$i" -lt "$OP_COUNT" ]; do
130 test_unsupported_op -k "${OP_STR[$i]}" "${OP_TKN[$i]}"
131
132 if [ $? -eq 1 ]; then
133 exit 1
134 fi
135
136 let "i++"
137 done
138}
139
5ed358a4
CB
140stop_lttng_sessiond
141
142# Cleanup
143rm -f $ENABLE_EVENT_STDERR
144rm -rf $TRACE_PATH
This page took 0.035939 seconds and 4 git commands to generate.