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