3 # SPDX-License-Identifier: GPL-2.0-only
5 # Copyright (C) 2019 EfficiOS Inc.
8 if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
9 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
11 UTILSSH
="$(dirname "$0")/../../utils/utils.sh"
14 # shellcheck source=../../utils/utils.sh
15 SH_TAP
=1 source "$UTILSSH"
19 data_dir
="${BT_TESTS_DATADIR}/cli/list-plugins"
20 plugin_dir
="${data_dir}"
22 stdout_file
=$
(mktemp
-t test_cli_list_plugins_stdout.XXXXXX
)
23 stderr_file
=$
(mktemp
-t test_cli_list_plugins_stderr.XXXXXX
)
24 grep_stdout_file
=$
(mktemp
-t test_cli_list_plugins_grep_stdout.XXXXXX
)
25 py_plugin_expected_stdout_file
=$
(mktemp
-t test_cli_list_plugins_expected_py_plugin_stdout.XXXXXX
)
28 bt_cli
"$stdout_file" "$stderr_file" \
29 --plugin-path "$plugin_dir" \
31 ok
"$?" "exit code is 0"
33 # Extract the section about our custom this-is-a-plugin Python plugin.
34 grep --after-context=11 '^this-is-a-plugin:$' "${stdout_file}" > "${grep_stdout_file}"
35 ok
"$?" "entry for this-is-a-plugin is present"
37 if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
38 platform_plugin_dir
=$
(cygpath
-m "${plugin_dir}")
40 platform_plugin_dir
="${plugin_dir}"
43 # Generate the expected output file for that plugin.
44 cat <<- EOF > "${py_plugin_expected_stdout_file}"
46 Path: ${platform_plugin_dir}/bt_plugin_list_plugins.py
49 Author: Jorge Mario Bergoglio
51 Source component classes:
52 'source.this-is-a-plugin.ThisIsASource'
53 Filter component classes:
54 'filter.this-is-a-plugin.ThisIsAFilter'
55 Sink component classes:
56 'sink.this-is-a-plugin.ThisIsASink'
59 # Compare the entry for this-is-a-plugin with the expected version.
60 bt_diff
"${py_plugin_expected_stdout_file}" "${grep_stdout_file}"
61 ok
"$?" "entry for this-is-a-plugin is as expected"
63 rm -f "${stdout_file}"
64 rm -f "${stderr_file}"
65 rm -f "${grep_stdout_file}"
66 rm -f "${py_plugin_expected_stdout_file}"