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.
18 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
19 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
21 UTILSSH
="$(dirname "$0")/../../utils/utils.sh"
24 # shellcheck source=../../utils/utils.sh
25 SH_TAP
=1 source "$UTILSSH"
29 data_dir
="${BT_TESTS_DATADIR}/cli/list-plugins"
30 plugin_dir
="${data_dir}"
32 stdout_file
=$
(mktemp
-t test_cli_list_plugins_stdout.XXXXXX
)
33 stderr_file
=$
(mktemp
-t test_cli_list_plugins_stderr.XXXXXX
)
34 grep_stdout_file
=$
(mktemp
-t test_cli_list_plugins_grep_stdout.XXXXXX
)
35 py_plugin_expected_stdout_file
=$
(mktemp
-t test_cli_list_plugins_expected_py_plugin_stdout.XXXXXX
)
38 bt_cli
"$stdout_file" "$stderr_file" \
39 --plugin-path "$plugin_dir" \
41 ok
"$?" "exit code is 0"
43 # Extract the section about our custom this-is-a-plugin Python plugin.
44 grep --after-context=11 '^this-is-a-plugin:$' "${stdout_file}" > "${grep_stdout_file}"
45 ok
"$?" "entry for this-is-a-plugin is present"
47 if [ "$BT_OS_TYPE" = "mingw" ]; then
48 platform_plugin_dir
=$
(cygpath
-m "${plugin_dir}")
50 platform_plugin_dir
="${plugin_dir}"
53 # Generate the expected output file for that plugin.
54 cat <<- EOF > "${py_plugin_expected_stdout_file}"
56 Path: ${platform_plugin_dir}/bt_plugin_list_plugins.py
59 Author: Jorge Mario Bergoglio
61 Source component classes:
62 'source.this-is-a-plugin.ThisIsASource'
63 Filter component classes:
64 'filter.this-is-a-plugin.ThisIsAFilter'
65 Sink component classes:
66 'sink.this-is-a-plugin.ThisIsASink'
69 # Compare the entry for this-is-a-plugin with the expected version.
70 bt_diff
"${py_plugin_expected_stdout_file}" "${grep_stdout_file}"
71 ok
"$?" "entry for this-is-a-plugin is as expected"
73 rm -f "${stdout_file}"
74 rm -f "${stderr_file}"
75 rm -f "${grep_stdout_file}"
76 rm -f "${py_plugin_expected_stdout_file}"