Change required clang-format version to 14
[babeltrace.git] / tests / cli / test_help
1 #!/bin/bash
2 #
3 # SPDX-License-Identifier: GPL-2.0-only
4 #
5 # Copyright (C) 2019 EfficiOS Inc.
6 #
7
8 SH_TAP=1
9
10 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
11 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
12 else
13 UTILSSH="$(dirname "$0")/../utils/utils.sh"
14 fi
15
16 # shellcheck source=../utils/utils.sh
17 source "$UTILSSH"
18
19 plan_tests 21
20
21 stdout=$(mktemp -t test_help_stdout.XXXXXX)
22 stderr=$(mktemp -t test_help_stderr.XXXXXX)
23
24 # Return 0 if file "$1" exists and is empty, non-0 otherwise.
25
26 is_empty()
27 {
28 [[ -f "$1" && ! -s "$1" ]]
29 }
30
31 # Test with a working plugin name.
32 bt_cli "${stdout}" "${stderr}" help ctf
33 ok $? "help ctf plugin exit status"
34
35 grep --silent 'Description: CTF input and output' "${stdout}"
36 ok $? "help ctf plugin expected output"
37
38 is_empty "${stderr}"
39 ok $? "help ctf plugin produces no error"
40
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"
44
45 grep --silent 'Description: Read CTF traces from the file system.' "${stdout}"
46 ok $? "help src.ctf.fs component class expected output"
47
48 is_empty "${stderr}"
49 ok $? "help src.ctf.fs component class produces no error"
50
51 # Test without parameter.
52 bt_cli "${stdout}" "${stderr}" help
53 isnt $? 0 "help without parameter exit status"
54
55 grep --silent "Missing plugin name or component class descriptor." "${stderr}"
56 ok $? "help without parameter produces expected error"
57
58 is_empty "${stdout}"
59 ok $? "help without parameter produces no output"
60
61 # Test with too many parameters.
62 bt_cli "${stdout}" "${stderr}" help ctf fs
63 isnt $? 0 "help with too many parameters exit status"
64
65 grep --silent "Extraneous command-line argument specified to \`help\` command:" "${stderr}"
66 ok $? "help with too many parameters produces expected error"
67
68 is_empty "${stdout}"
69 ok $? "help with too many parameters produces no output"
70
71 # Test with unknown plugin name.
72 bt_cli "${stdout}" "${stderr}" help zigotos
73 isnt $? 0 "help with unknown plugin name"
74
75 grep --silent 'Cannot find plugin: plugin-name="zigotos"' "${stderr}"
76 ok $? "help with unknown plugin name produces expected error"
77
78 is_empty "${stdout}"
79 ok $? "help with unknown plugin name produces no output"
80
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"
84
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"
87
88 grep --silent 'Description: CTF input and output' "${stdout}"
89 ok $? "help with unknown component class name prints plugin help"
90
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"
94
95 grep --silent 'Cannot find plugin: plugin-name="bob"' "${stderr}"
96 ok $? "help with unknown component class plugin produces expected error"
97
98 is_empty "${stdout}"
99 ok $? "help with unknown component class plugin produces no output"
100
101 rm -f "${stdout}" "${stderr}"
This page took 0.031744 seconds and 4 git commands to generate.