3 # SPDX-License-Identifier: GPL-2.0-only
5 # Copyright (C) 2019 EfficiOS Inc.
10 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
11 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
13 UTILSSH
="$(dirname "$0")/../utils/utils.sh"
16 # shellcheck source=../utils/utils.sh
21 stdout
=$
(mktemp
-t test_help_stdout.XXXXXX
)
22 stderr
=$
(mktemp
-t test_help_stderr.XXXXXX
)
24 # Return 0 if file "$1" exists and is empty, non-0 otherwise.
28 [[ -f "$1" && ! -s "$1" ]]
31 # Test with a working plugin name.
32 bt_cli
"${stdout}" "${stderr}" help ctf
33 ok $?
"help ctf plugin exit status"
35 grep --silent 'Description: CTF input and output' "${stdout}"
36 ok $?
"help ctf plugin expected output"
39 ok $?
"help ctf plugin produces no error"
41 # Test with a working component class name.
42 bt_cli
"${stdout}" "${stderr}" help src.ctf.fs
43 ok $?
"help src.ctf.fs component class exit status"
45 grep --silent 'Description: Read CTF traces from the file system.' "${stdout}"
46 ok $?
"help src.ctf.fs component class expected output"
49 ok $?
"help src.ctf.fs component class produces no error"
51 # Test without parameter.
52 bt_cli
"${stdout}" "${stderr}" help
53 isnt $?
0 "help without parameter exit status"
55 grep --silent "Missing plugin name or component class descriptor." "${stderr}"
56 ok $?
"help without parameter produces expected error"
59 ok $?
"help without parameter produces no output"
61 # Test with too many parameters.
62 bt_cli
"${stdout}" "${stderr}" help ctf fs
63 isnt $?
0 "help with too many parameters exit status"
65 grep --silent "Extraneous command-line argument specified to \`help\` command:" "${stderr}"
66 ok $?
"help with too many parameters produces expected error"
69 ok $?
"help with too many parameters produces no output"
71 # Test with unknown plugin name.
72 bt_cli
"${stdout}" "${stderr}" help zigotos
73 isnt $?
0 "help with unknown plugin name"
75 grep --silent 'Cannot find plugin: plugin-name="zigotos"' "${stderr}"
76 ok $?
"help with unknown plugin name produces expected error"
79 ok $?
"help with unknown plugin name produces no output"
81 # Test with unknown component class name (but known plugin).
82 bt_cli
"${stdout}" "${stderr}" help src.ctf.bob
83 isnt $?
0 "help with unknown component class name"
85 grep --silent 'Cannot find component class: plugin-name="ctf", comp-cls-name="bob", comp-cls-type=SOURCE' "${stderr}"
86 ok $?
"help with unknown component class name produces expected error"
88 grep --silent 'Description: CTF input and output' "${stdout}"
89 ok $?
"help with unknown component class name prints plugin help"
91 # Test with unknown component class plugin
92 bt_cli
"${stdout}" "${stderr}" help src.bob.fs
93 isnt $?
0 "help with unknown component class plugin"
95 grep --silent 'Cannot find plugin: plugin-name="bob"' "${stderr}"
96 ok $?
"help with unknown component class plugin produces expected error"
99 ok $?
"help with unknown component class plugin produces no output"
101 rm -f "${stdout}" "${stderr}"
This page took 0.031145 seconds and 4 git commands to generate.