Commit | Line | Data |
---|---|---|
7b8c5132 SM |
1 | #!/bin/bash |
2 | # | |
0235b0db | 3 | # SPDX-License-Identifier: GPL-2.0-only |
7b8c5132 | 4 | # |
0235b0db | 5 | # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com> |
7b8c5132 | 6 | # |
7b8c5132 SM |
7 | |
8 | # Test how parameters are applied to sources auto-discovered by the convert | |
9 | # command. | |
10 | ||
75e396f6 | 11 | if [ -n "${BT_TESTS_SRCDIR:-}" ]; then |
7b8c5132 SM |
12 | UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" |
13 | else | |
14 | UTILSSH="$(dirname "$0")/../../utils/utils.sh" | |
15 | fi | |
16 | ||
17 | # shellcheck source=../../utils/utils.sh | |
18 | SH_TAP=1 source "$UTILSSH" | |
19 | ||
3971c701 | 20 | NUM_TESTS=9 |
7b8c5132 SM |
21 | |
22 | plan_tests $NUM_TESTS | |
23 | ||
24 | data_dir="${BT_TESTS_DATADIR}/cli/params" | |
25 | plugin_dir="${data_dir}" | |
26 | ||
27 | expected_file=$(mktemp -t expected.XXXXXX) | |
28 | ||
29 | function expect_success | |
30 | { | |
31 | local test_name="$1" | |
32 | local params_str="$2" | |
33 | local expected_str="$3" | |
34 | ||
35 | echo "$expected_str" > "$expected_file" | |
36 | ||
37 | bt_diff_cli "$expected_file" /dev/null --plugin-path "$plugin_dir" -c "src.text.dmesg" \ | |
38 | -c "sink.params.SinkThatPrintsParams" --params "$params_str" | |
39 | ok "$?" "$test_name" | |
40 | } | |
41 | ||
42 | expect_success 'null' 'a=null,b=nul,c=NULL' \ | |
43 | '{a=None, b=None, c=None}' | |
44 | expect_success 'bool' 'a=true,b=TRUE,c=yes,d=YES,e=false,f=FALSE,g=no,h=NO' \ | |
45 | '{a=True, b=True, c=True, d=True, e=False, f=False, g=False, h=False}' | |
46 | expect_success 'signed integer' 'a=0b110, b=022, c=22, d=0x22' \ | |
47 | '{a=6, b=18, c=22, d=34}' | |
48 | expect_success 'unsigned integer' 'a=+0b110, b=+022, c=+22, d=+0x22' \ | |
49 | '{a=6u, b=18u, c=22u, d=34u}' | |
50 | expect_success 'string' 'a="avril lavigne", b=patata, c="This\"is\\escaped"' \ | |
51 | '{a=avril lavigne, b=patata, c=This"is\escaped}' | |
52 | expect_success 'float' 'a=1.234, b=17., c=.28, d=-18.28' \ | |
53 | '{a=1.234, b=17.0, c=0.28, d=-18.28}' | |
54 | expect_success 'float scientific notation' 'a=10.5e6, b=10.5E6, c=10.5e-6, d=10.5E-6' \ | |
55 | '{a=10500000.0, b=10500000.0, c=1.05e-05, d=1.05e-05}' | |
56 | expect_success 'array' 'a=[1, [["hi",]]]' \ | |
57 | '{a=[1, [[hi]]]}' | |
b1df972d | 58 | expect_success 'map' 'a=4,a={},b={salut="la gang",comment="ca va",oh={x=2}}' \ |
3971c701 | 59 | '{a={}, b={comment=ca va, oh={x=2}, salut=la gang}}' |
7b8c5132 SM |
60 | |
61 | rm -f "$expected_file" |