lib: rename parameter of bt_self_component_filter_add_{in,out}put_port
[babeltrace.git] / tests / bindings / python / bt2 / test_plugin.py
CommitLineData
d2d857a8
MJ
1#
2# Copyright (C) 2019 EfficiOS Inc.
3#
4# This program is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License
6# as published by the Free Software Foundation; only version 2
7# of the License.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17#
18
811644b8 19import unittest
811644b8
PP
20import bt2
21import bt2.plugin
22import os
23
24
25_TEST_PLUGIN_PLUGINS_PATH = os.environ['TEST_PLUGIN_PLUGINS_PATH']
26
27
28class PluginSetTestCase(unittest.TestCase):
29 def test_create(self):
30 pset = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH)
31 self.assertTrue(len(pset) >= 3)
32
33 def test_getitem(self):
34 pset = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH)
35 self.assertTrue(pset[0].path.startswith(_TEST_PLUGIN_PLUGINS_PATH))
36
37 def test_iter(self):
38 pset = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH)
39 names = set()
40
41 for plugin in pset:
42 names.add(plugin.name)
43
44 self.assertTrue('ctf' in names)
45 self.assertTrue('utils' in names)
46 self.assertTrue('text' in names)
47
48
49class FindPluginsTestCase(unittest.TestCase):
50 def test_find_none(self):
51 pset = bt2.find_plugins('/this/does/not/exist/246703df-cb85-46d5-8406-5e8dc4a88b41')
52 self.assertIsNone(pset)
53
54 def test_find_dir(self):
55 pset = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH)
56 self.assertTrue(len(pset) >= 3)
57
ab1bca6c
SM
58 def test_find_file(self):
59 path = os.path.join(_TEST_PLUGIN_PLUGINS_PATH, 'utils', '.libs', 'babeltrace-plugin-utils.so')
60 pset = bt2.find_plugins(path)
61 self.assertTrue(len(pset) == 1)
62
811644b8
PP
63
64class FindPluginTestCase(unittest.TestCase):
65 def test_find_none(self):
66 plugin = bt2.find_plugin('this-does-not-exist-246703df-cb85-46d5-8406-5e8dc4a88b41')
67 self.assertIsNone(plugin)
68
69 def test_find_existing(self):
70 plugin = bt2.find_plugin('ctf')
71 self.assertIsInstance(plugin, bt2.plugin._Plugin)
72
73
74class PluginTestCase(unittest.TestCase):
75 def setUp(self):
76 self._plugin = bt2.find_plugin('ctf')
77
78 def tearDown(self):
79 del self._plugin
80
81 def test_name(self):
82 self.assertEqual(self._plugin.name, 'ctf')
83
84 def test_path(self):
9769184f
MJ
85 plugin_path = os.path.normcase(self._plugin.path)
86 plugin_path_env = os.path.normcase(_TEST_PLUGIN_PLUGINS_PATH)
87 self.assertTrue(plugin_path.startswith(plugin_path_env))
811644b8
PP
88
89 def test_author(self):
90 self.assertTrue('Philippe Proulx' in self._plugin.author)
91
92 def test_license(self):
93 self.assertTrue('MIT' in self._plugin.license)
94
95 def test_description(self):
96 self.assertTrue('CTF source and sink support' in self._plugin.description)
97
98 def test_version(self):
99 self.assertIsNone(self._plugin.version)
100
101 def test_source_comp_classes_len(self):
102 self.assertEqual(len(self._plugin.source_component_classes), 2)
103
104 def test_source_comp_classes_getitem(self):
105 self.assertEqual(self._plugin.source_component_classes['fs'].name, 'fs')
106
107 def test_source_comp_classes_getitem_invalid(self):
108 with self.assertRaises(KeyError):
109 self._plugin.source_component_classes['lol']
110
111 def test_source_comp_classes_iter(self):
112 plugins = {}
113
114 for cc_name, cc in self._plugin.source_component_classes.items():
115 plugins[cc_name] = cc
116
117 self.assertTrue('fs' in plugins)
118 self.assertTrue('lttng-live' in plugins)
119 self.assertEqual(plugins['fs'].name, 'fs')
120 self.assertEqual(plugins['lttng-live'].name, 'lttng-live')
121
122 def test_filter_comp_classes_len(self):
123 plugin = bt2.find_plugin('utils')
124 self.assertEqual(len(plugin.filter_component_classes), 2)
125
126 def test_sink_comp_classes_len(self):
127 self.assertEqual(len(self._plugin.sink_component_classes), 1)
This page took 0.035771 seconds and 4 git commands to generate.