Tests: Convert the tools filtering tests output to TAP
[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)
03276eea 27NUM_TESTS=46
9ac429ef 28source $TESTDIR/utils/utils.sh
5ed358a4
CB
29
30print_test_banner "$TEST_DESC"
31
32function enable_ust_lttng_event_filter_unsupported
33{
34 sess_name=$1
35 event_name=$2
36 filter=$3
37
5ed358a4
CB
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
03276eea 43 fail "Enable lttng event with filtering and unsupported operator"
5ed358a4
CB
44 return 1
45 else
03276eea 46 pass "Enable lttng event with filtering and unsupported operator"
5ed358a4
CB
47 return 0
48 fi
49}
50
51function test_unsupported_op
52{
53 test_op_str=$1
54 test_op_tkn=$2
55
03276eea 56 diag "Test filter expression with unsupported operator $test_op_str ($test_op_tkn)"
5ed358a4
CB
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
03276eea 72
5ed358a4
CB
73 grep -i -q "not[[:space:]]\+supported" $ENABLE_EVENT_STDERR
74
75 if [ $? -eq 1 ]; then
03276eea 76 fail "Unsupported operator test $test_op_str ($test_op_tkn)"
5ed358a4
CB
77 return 1
78 else
03276eea 79 pass "Unsupported operator test $test_op_str ($test_op_tkn)"
5ed358a4
CB
80 fi
81
82 # Destroy session
83 destroy_lttng_session $SESSION_NAME
84 return 0
85}
86
03276eea
CB
87plan_tests $NUM_TESTS
88
5ed358a4
CB
89# Unsupported operators
90OP_STR=("MUL" "DIV" "MOD" "PLUS" "MINUS" "LSHIFT" "RSHIFT"
91 "BIN_AND" "BIN_OR" "BIN_XOR" "UNARY_BIN_NOT")
92
93OP_TKN=("*" "/" "%" "+" "-" "<<" ">>" "&" "|" "^" "~")
94
95OP_COUNT=${#OP_STR[@]}
96i=0
97
98start_lttng_sessiond
99
100while [ "$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++"
108done
109
110stop_lttng_sessiond
111
112# Cleanup
113rm -f $ENABLE_EVENT_STDERR
114rm -rf $TRACE_PATH
This page took 0.027274 seconds and 4 git commands to generate.