3 # Copyright (C) 2019 EfficiOS Inc.
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.
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
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.
20 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
21 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
23 UTILSSH
="$(dirname "$0")/../utils/utils.sh"
26 # shellcheck source=../utils/utils.sh
31 stdout
=$
(mktemp
-t test_help_stdout.XXXXXX
)
32 stderr
=$
(mktemp
-t test_help_stderr.XXXXXX
)
34 # Return 0 if file "$1" exists and is empty, non-0 otherwise.
38 [[ -f "$1" && ! -s "$1" ]]
41 # Test with a working plugin name.
42 bt_cli
"${stdout}" "${stderr}" help ctf
43 ok $?
"help ctf plugin exit status"
45 grep --silent 'Description: CTF input and output' "${stdout}"
46 ok $?
"help ctf plugin expected output"
49 ok $?
"help ctf plugin produces no error"
51 # Test with a working component class name.
52 bt_cli
"${stdout}" "${stderr}" help src.ctf.fs
53 ok $?
"help src.ctf.fs component class exit status"
55 grep --silent 'Description: Read CTF traces from the file system.' "${stdout}"
56 ok $?
"help src.ctf.fs component class expected output"
59 ok $?
"help src.ctf.fs component class produces no error"
61 # Test without parameter.
62 bt_cli
"${stdout}" "${stderr}" help
63 isnt $?
0 "help without parameter exit status"
65 grep --silent "Missing plugin name or component class descriptor." "${stderr}"
66 ok $?
"help without parameter produces expected error"
69 ok $?
"help without parameter produces no output"
71 # Test with too many parameters.
72 bt_cli
"${stdout}" "${stderr}" help ctf fs
73 isnt $?
0 "help with too many parameters exit status"
75 grep --silent "Extraneous command-line argument specified to \`help\` command:" "${stderr}"
76 ok $?
"help with too many parameters produces expected error"
79 ok $?
"help with too many parameters produces no output"
81 # Test with unknown plugin name.
82 bt_cli
"${stdout}" "${stderr}" help zigotos
83 isnt $?
0 "help with unknown plugin name"
85 grep --silent 'Cannot find plugin: plugin-name="zigotos"' "${stderr}"
86 ok $?
"help with unknown plugin name produces expected error"
89 ok $?
"help with unknown plugin name produces no output"
91 # Test with unknown component class name (but known plugin).
92 bt_cli
"${stdout}" "${stderr}" help src.ctf.bob
93 isnt $?
0 "help with unknown component class name"
95 grep --silent 'Cannot find component class: plugin-name="ctf", comp-cls-name="bob", comp-cls-type=1' "${stderr}"
96 ok $?
"help with unknown component class name produces expected error"
98 grep --silent 'Description: CTF input and output' "${stdout}"
99 ok $?
"help with unknown component class name prints plugin help"
101 # Test with unknown component class plugin
102 bt_cli
"${stdout}" "${stderr}" help src.bob.fs
103 isnt $?
0 "help with unknown component class plugin"
105 grep --silent 'Cannot find plugin: plugin-name="bob"' "${stderr}"
106 ok $?
"help with unknown component class plugin produces expected error"
109 ok $?
"help with unknown component class plugin produces no output"
111 rm -f "${stdout}" "${stderr}"
This page took 0.033117 seconds and 4 git commands to generate.