9 _TEST_PLUGIN_PLUGINS_PATH
= os
.environ
['TEST_PLUGIN_PLUGINS_PATH']
12 class PluginSetTestCase(unittest
.TestCase
):
13 def test_create(self
):
14 pset
= bt2
.find_plugins(_TEST_PLUGIN_PLUGINS_PATH
)
15 self
.assertTrue(len(pset
) >= 3)
17 def test_getitem(self
):
18 pset
= bt2
.find_plugins(_TEST_PLUGIN_PLUGINS_PATH
)
19 self
.assertTrue(pset
[0].path
.startswith(_TEST_PLUGIN_PLUGINS_PATH
))
22 pset
= bt2
.find_plugins(_TEST_PLUGIN_PLUGINS_PATH
)
26 names
.add(plugin
.name
)
28 self
.assertTrue('ctf' in names
)
29 self
.assertTrue('utils' in names
)
30 self
.assertTrue('text' in names
)
33 class FindPluginsTestCase(unittest
.TestCase
):
34 def test_find_none(self
):
35 pset
= bt2
.find_plugins('/this/does/not/exist/246703df-cb85-46d5-8406-5e8dc4a88b41')
36 self
.assertIsNone(pset
)
38 def test_find_dir(self
):
39 pset
= bt2
.find_plugins(_TEST_PLUGIN_PLUGINS_PATH
)
40 self
.assertTrue(len(pset
) >= 3)
43 class FindPluginTestCase(unittest
.TestCase
):
44 def test_find_none(self
):
45 plugin
= bt2
.find_plugin('this-does-not-exist-246703df-cb85-46d5-8406-5e8dc4a88b41')
46 self
.assertIsNone(plugin
)
48 def test_find_existing(self
):
49 plugin
= bt2
.find_plugin('ctf')
50 self
.assertIsInstance(plugin
, bt2
.plugin
._Plugin
)
53 class PluginTestCase(unittest
.TestCase
):
55 self
._plugin
= bt2
.find_plugin('ctf')
61 self
.assertEqual(self
._plugin
.name
, 'ctf')
64 plugin_path
= os
.path
.normcase(self
._plugin
.path
)
65 plugin_path_env
= os
.path
.normcase(_TEST_PLUGIN_PLUGINS_PATH
)
66 self
.assertTrue(plugin_path
.startswith(plugin_path_env
))
68 def test_author(self
):
69 self
.assertTrue('Philippe Proulx' in self
._plugin
.author
)
71 def test_license(self
):
72 self
.assertTrue('MIT' in self
._plugin
.license
)
74 def test_description(self
):
75 self
.assertTrue('CTF source and sink support' in self
._plugin
.description
)
77 def test_version(self
):
78 self
.assertIsNone(self
._plugin
.version
)
80 def test_source_comp_classes_len(self
):
81 self
.assertEqual(len(self
._plugin
.source_component_classes
), 2)
83 def test_source_comp_classes_getitem(self
):
84 self
.assertEqual(self
._plugin
.source_component_classes
['fs'].name
, 'fs')
86 def test_source_comp_classes_getitem_invalid(self
):
87 with self
.assertRaises(KeyError):
88 self
._plugin
.source_component_classes
['lol']
90 def test_source_comp_classes_iter(self
):
93 for cc_name
, cc
in self
._plugin
.source_component_classes
.items():
96 self
.assertTrue('fs' in plugins
)
97 self
.assertTrue('lttng-live' in plugins
)
98 self
.assertEqual(plugins
['fs'].name
, 'fs')
99 self
.assertEqual(plugins
['lttng-live'].name
, 'lttng-live')
101 def test_filter_comp_classes_len(self
):
102 plugin
= bt2
.find_plugin('utils')
103 self
.assertEqual(len(plugin
.filter_component_classes
), 2)
105 def test_sink_comp_classes_len(self
):
106 self
.assertEqual(len(self
._plugin
.sink_component_classes
), 1)