7 _TEST_PLUGIN_PLUGINS_PATH
= os
.environ
['TEST_PLUGIN_PLUGINS_PATH']
10 class PluginSetTestCase(unittest
.TestCase
):
11 def test_create(self
):
12 pset
= bt2
.find_plugins(_TEST_PLUGIN_PLUGINS_PATH
)
13 self
.assertTrue(len(pset
) >= 3)
15 def test_getitem(self
):
16 pset
= bt2
.find_plugins(_TEST_PLUGIN_PLUGINS_PATH
)
17 self
.assertTrue(pset
[0].path
.startswith(_TEST_PLUGIN_PLUGINS_PATH
))
20 pset
= bt2
.find_plugins(_TEST_PLUGIN_PLUGINS_PATH
)
24 names
.add(plugin
.name
)
26 self
.assertTrue('ctf' in names
)
27 self
.assertTrue('utils' in names
)
28 self
.assertTrue('text' in names
)
31 class FindPluginsTestCase(unittest
.TestCase
):
32 def test_find_none(self
):
33 pset
= bt2
.find_plugins('/this/does/not/exist/246703df-cb85-46d5-8406-5e8dc4a88b41')
34 self
.assertIsNone(pset
)
36 def test_find_dir(self
):
37 pset
= bt2
.find_plugins(_TEST_PLUGIN_PLUGINS_PATH
)
38 self
.assertTrue(len(pset
) >= 3)
40 def test_find_file(self
):
41 path
= os
.path
.join(_TEST_PLUGIN_PLUGINS_PATH
, 'utils', '.libs', 'babeltrace-plugin-utils.so')
42 pset
= bt2
.find_plugins(path
)
43 self
.assertTrue(len(pset
) == 1)
46 class FindPluginTestCase(unittest
.TestCase
):
47 def test_find_none(self
):
48 plugin
= bt2
.find_plugin('this-does-not-exist-246703df-cb85-46d5-8406-5e8dc4a88b41')
49 self
.assertIsNone(plugin
)
51 def test_find_existing(self
):
52 plugin
= bt2
.find_plugin('ctf')
53 self
.assertIsInstance(plugin
, bt2
.plugin
._Plugin
)
56 class PluginTestCase(unittest
.TestCase
):
58 self
._plugin
= bt2
.find_plugin('ctf')
64 self
.assertEqual(self
._plugin
.name
, 'ctf')
67 plugin_path
= os
.path
.normcase(self
._plugin
.path
)
68 plugin_path_env
= os
.path
.normcase(_TEST_PLUGIN_PLUGINS_PATH
)
69 self
.assertTrue(plugin_path
.startswith(plugin_path_env
))
71 def test_author(self
):
72 self
.assertTrue('Philippe Proulx' in self
._plugin
.author
)
74 def test_license(self
):
75 self
.assertTrue('MIT' in self
._plugin
.license
)
77 def test_description(self
):
78 self
.assertTrue('CTF source and sink support' in self
._plugin
.description
)
80 def test_version(self
):
81 self
.assertIsNone(self
._plugin
.version
)
83 def test_source_comp_classes_len(self
):
84 self
.assertEqual(len(self
._plugin
.source_component_classes
), 2)
86 def test_source_comp_classes_getitem(self
):
87 self
.assertEqual(self
._plugin
.source_component_classes
['fs'].name
, 'fs')
89 def test_source_comp_classes_getitem_invalid(self
):
90 with self
.assertRaises(KeyError):
91 self
._plugin
.source_component_classes
['lol']
93 def test_source_comp_classes_iter(self
):
96 for cc_name
, cc
in self
._plugin
.source_component_classes
.items():
99 self
.assertTrue('fs' in plugins
)
100 self
.assertTrue('lttng-live' in plugins
)
101 self
.assertEqual(plugins
['fs'].name
, 'fs')
102 self
.assertEqual(plugins
['lttng-live'].name
, 'lttng-live')
104 def test_filter_comp_classes_len(self
):
105 plugin
= bt2
.find_plugin('utils')
106 self
.assertEqual(len(plugin
.filter_component_classes
), 2)
108 def test_sink_comp_classes_len(self
):
109 self
.assertEqual(len(self
._plugin
.sink_component_classes
), 1)