tests: add test for list-plugins CLI command
[babeltrace.git] / tests / cli / list-plugins / test_list_plugins
CommitLineData
4a879f40
SM
1#!/bin/bash
2#
3# Copyright (C) 2019 EfficiOS Inc.
4#
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.
8#
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
12# more details.
13#
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.
17
18if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
19 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
20else
21 UTILSSH="$(dirname "$0")/../../utils/utils.sh"
22fi
23
24# shellcheck source=../../utils/utils.sh
25SH_TAP=1 source "$UTILSSH"
26
27plan_tests 3
28
29data_dir="${BT_TESTS_DATADIR}/cli/list-plugins"
30plugin_dir="${data_dir}"
31
32stdout_file=$(mktemp -t test_cli_list_plugins_stdout.XXXXXX)
33stderr_file=$(mktemp -t test_cli_list_plugins_stderr.XXXXXX)
34grep_stdout_file=$(mktemp -t test_cli_list_plugins_grep_stdout.XXXXXX)
35py_plugin_expected_stdout_file=$(mktemp -t test_cli_list_plugins_expected_py_plugin_stdout.XXXXXX)
36
37# Run list-plugins.
38bt_cli "$stdout_file" "$stderr_file" \
39 --plugin-path "$plugin_dir" \
40 list-plugins
41ok "$?" "exit code is 0"
42
43# Extract the section about our custom this-is-a-plugin Python plugin.
44grep --after-context=11 '^this-is-a-plugin:$' "${stdout_file}" > "${grep_stdout_file}"
45ok "$?" "entry for this-is-a-plugin is present"
46
47if [ "$BT_OS_TYPE" = "mingw" ]; then
48 platform_plugin_dir=$(cygpath -m "${plugin_dir}")
49else
50 platform_plugin_dir="${plugin_dir}"
51fi
52
53# Generate the expected output file for that plugin.
54cat <<- EOF > "${py_plugin_expected_stdout_file}"
55 this-is-a-plugin:
56 Path: ${platform_plugin_dir}/bt_plugin_list_plugins.py
57 Version: 1.2.3bob
58 Description: A plugin
59 Author: Jorge Mario Bergoglio
60 License: The license
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'
67EOF
68
69# Compare the entry for this-is-a-plugin with the expected version.
70bt_diff "${py_plugin_expected_stdout_file}" "${grep_stdout_file}"
71ok "$?" "entry for this-is-a-plugin is as expected"
72
73rm -f "${stdout_file}"
74rm -f "${stderr_file}"
75rm -f "${grep_stdout_file}"
76rm -f "${py_plugin_expected_stdout_file}"
This page took 0.025621 seconds and 4 git commands to generate.