lib: use powers of two for object type enumerators
[babeltrace.git] / tests / cli / test_help
CommitLineData
4bf5c85f
SM
1#!/bin/bash
2#
3# Copyright (C) 2019 EfficiOS Inc.
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
18SH_TAP=1
19
20if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
21 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
22else
23 UTILSSH="$(dirname "$0")/../utils/utils.sh"
24fi
25
26# shellcheck source=../utils/utils.sh
27source "$UTILSSH"
28
29plan_tests 21
30
365a0459
SM
31stdout=$(mktemp -t test_help_stdout.XXXXXX)
32stderr=$(mktemp -t test_help_stderr.XXXXXX)
4bf5c85f
SM
33
34# Return 0 if file "$1" exists and is empty, non-0 otherwise.
35
36is_empty()
37{
38 [[ -f "$1" && ! -s "$1" ]]
39}
40
41# Test with a working plugin name.
42bt_cli "${stdout}" "${stderr}" help ctf
43ok $? "help ctf plugin exit status"
44
45grep --silent 'Description: CTF input and output' "${stdout}"
46ok $? "help ctf plugin expected output"
47
48is_empty "${stderr}"
49ok $? "help ctf plugin produces no error"
50
51# Test with a working component class name.
52bt_cli "${stdout}" "${stderr}" help src.ctf.fs
53ok $? "help src.ctf.fs component class exit status"
54
55grep --silent 'Description: Read CTF traces from the file system.' "${stdout}"
56ok $? "help src.ctf.fs component class expected output"
57
58is_empty "${stderr}"
59ok $? "help src.ctf.fs component class produces no error"
60
61# Test without parameter.
62bt_cli "${stdout}" "${stderr}" help
63isnt $? 0 "help without parameter exit status"
64
65grep --silent "Missing plugin name or component class descriptor." "${stderr}"
66ok $? "help without parameter produces expected error"
67
68is_empty "${stdout}"
69ok $? "help without parameter produces no output"
70
71# Test with too many parameters.
72bt_cli "${stdout}" "${stderr}" help ctf fs
73isnt $? 0 "help with too many parameters exit status"
74
75grep --silent "Extraneous command-line argument specified to \`help\` command:" "${stderr}"
76ok $? "help with too many parameters produces expected error"
77
78is_empty "${stdout}"
79ok $? "help with too many parameters produces no output"
80
81# Test with unknown plugin name.
82bt_cli "${stdout}" "${stderr}" help zigotos
83isnt $? 0 "help with unknown plugin name"
84
85grep --silent 'Cannot find plugin: plugin-name="zigotos"' "${stderr}"
86ok $? "help with unknown plugin name produces expected error"
87
88is_empty "${stdout}"
89ok $? "help with unknown plugin name produces no output"
90
91# Test with unknown component class name (but known plugin).
92bt_cli "${stdout}" "${stderr}" help src.ctf.bob
93isnt $? 0 "help with unknown component class name"
94
9c3869a9 95grep --silent 'Cannot find component class: plugin-name="ctf", comp-cls-name="bob", comp-cls-type=1' "${stderr}"
4bf5c85f
SM
96ok $? "help with unknown component class name produces expected error"
97
98grep --silent 'Description: CTF input and output' "${stdout}"
99ok $? "help with unknown component class name prints plugin help"
100
101# Test with unknown component class plugin
102bt_cli "${stdout}" "${stderr}" help src.bob.fs
103isnt $? 0 "help with unknown component class plugin"
104
105grep --silent 'Cannot find plugin: plugin-name="bob"' "${stderr}"
106ok $? "help with unknown component class plugin produces expected error"
107
108is_empty "${stdout}"
109ok $? "help with unknown component class plugin produces no output"
365a0459
SM
110
111rm -f "${stdout}" "${stderr}"
This page took 0.027373 seconds and 4 git commands to generate.