bt2: validate parameters to _StreamClass.create_event_class before creating the nativ...
[babeltrace.git] / tests / cli / params / test_params
CommitLineData
7b8c5132
SM
1#!/bin/bash
2#
3# Copyright (C) 2019 Simon Marchi <simon.marchi@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 how parameters are applied to sources auto-discovered by the convert
19# command.
20
21if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
22 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
23else
24 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
25fi
26
27# shellcheck source=../../utils/utils.sh
28SH_TAP=1 source "$UTILSSH"
29
3971c701 30NUM_TESTS=9
7b8c5132
SM
31
32plan_tests $NUM_TESTS
33
34data_dir="${BT_TESTS_DATADIR}/cli/params"
35plugin_dir="${data_dir}"
36
37expected_file=$(mktemp -t expected.XXXXXX)
38
39function expect_success
40{
41 local test_name="$1"
42 local params_str="$2"
43 local expected_str="$3"
44
45 echo "$expected_str" > "$expected_file"
46
47 bt_diff_cli "$expected_file" /dev/null --plugin-path "$plugin_dir" -c "src.text.dmesg" \
48 -c "sink.params.SinkThatPrintsParams" --params "$params_str"
49 ok "$?" "$test_name"
50}
51
52expect_success 'null' 'a=null,b=nul,c=NULL' \
53 '{a=None, b=None, c=None}'
54expect_success 'bool' 'a=true,b=TRUE,c=yes,d=YES,e=false,f=FALSE,g=no,h=NO' \
55 '{a=True, b=True, c=True, d=True, e=False, f=False, g=False, h=False}'
56expect_success 'signed integer' 'a=0b110, b=022, c=22, d=0x22' \
57 '{a=6, b=18, c=22, d=34}'
58expect_success 'unsigned integer' 'a=+0b110, b=+022, c=+22, d=+0x22' \
59 '{a=6u, b=18u, c=22u, d=34u}'
60expect_success 'string' 'a="avril lavigne", b=patata, c="This\"is\\escaped"' \
61 '{a=avril lavigne, b=patata, c=This"is\escaped}'
62expect_success 'float' 'a=1.234, b=17., c=.28, d=-18.28' \
63 '{a=1.234, b=17.0, c=0.28, d=-18.28}'
64expect_success 'float scientific notation' 'a=10.5e6, b=10.5E6, c=10.5e-6, d=10.5E-6' \
65 '{a=10500000.0, b=10500000.0, c=1.05e-05, d=1.05e-05}'
66expect_success 'array' 'a=[1, [["hi",]]]' \
67 '{a=[1, [[hi]]]}'
3971c701
SM
68expect_success 'map' 'a={},b={salut="la gang",comment="ca va",oh={x=2}}' \
69 '{a={}, b={comment=ca va, oh={x=2}, salut=la gang}}'
7b8c5132
SM
70
71rm -f "$expected_file"
This page took 0.032967 seconds and 4 git commands to generate.