Commit | Line | Data |
---|---|---|
ae0bfae8 | 1 | from bt2 import value |
f6a5e476 PP |
2 | import unittest |
3 | import copy | |
4 | import bt2 | |
5 | import bt2.plugin | |
6 | import os | |
7 | ||
8 | ||
9 | _TEST_PLUGIN_PLUGINS_PATH = os.environ['TEST_PLUGIN_PLUGINS_PATH'] | |
10 | ||
11 | ||
90cfc012 | 12 | @unittest.skip("this is broken") |
f6a5e476 PP |
13 | class PluginSetTestCase(unittest.TestCase): |
14 | def test_create(self): | |
15 | pset = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH) | |
16 | self.assertTrue(len(pset) >= 3) | |
17 | ||
18 | def test_getitem(self): | |
19 | pset = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH) | |
20 | self.assertTrue(pset[0].path.startswith(_TEST_PLUGIN_PLUGINS_PATH)) | |
21 | ||
22 | def test_iter(self): | |
23 | pset = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH) | |
24 | names = set() | |
25 | ||
26 | for plugin in pset: | |
27 | names.add(plugin.name) | |
28 | ||
29 | self.assertTrue('ctf' in names) | |
30 | self.assertTrue('utils' in names) | |
31 | self.assertTrue('text' in names) | |
32 | ||
33 | ||
90cfc012 | 34 | @unittest.skip("this is broken") |
f6a5e476 PP |
35 | class FindPluginsTestCase(unittest.TestCase): |
36 | def test_find_none(self): | |
37 | pset = bt2.find_plugins('/this/does/not/exist/246703df-cb85-46d5-8406-5e8dc4a88b41') | |
38 | self.assertIsNone(pset) | |
39 | ||
40 | def test_find_dir(self): | |
41 | pset = bt2.find_plugins(_TEST_PLUGIN_PLUGINS_PATH) | |
42 | self.assertTrue(len(pset) >= 3) | |
43 | ||
44 | ||
90cfc012 | 45 | @unittest.skip("this is broken") |
f6a5e476 PP |
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) | |
50 | ||
51 | def test_find_existing(self): | |
52 | plugin = bt2.find_plugin('ctf') | |
53 | self.assertIsInstance(plugin, bt2.plugin._Plugin) | |
54 | ||
55 | ||
90cfc012 | 56 | @unittest.skip("this is broken") |
f6a5e476 PP |
57 | class PluginTestCase(unittest.TestCase): |
58 | def setUp(self): | |
59 | self._plugin = bt2.find_plugin('ctf') | |
60 | ||
61 | def tearDown(self): | |
62 | del self._plugin | |
63 | ||
64 | def test_name(self): | |
65 | self.assertEqual(self._plugin.name, 'ctf') | |
66 | ||
67 | def test_path(self): | |
0592c0fe MJ |
68 | plugin_path = os.path.normcase(self._plugin.path) |
69 | plugin_path_env = os.path.normcase(_TEST_PLUGIN_PLUGINS_PATH) | |
70 | self.assertTrue(plugin_path.startswith(plugin_path_env)) | |
f6a5e476 PP |
71 | |
72 | def test_author(self): | |
73 | self.assertTrue('Philippe Proulx' in self._plugin.author) | |
74 | ||
75 | def test_license(self): | |
76 | self.assertTrue('MIT' in self._plugin.license) | |
77 | ||
78 | def test_description(self): | |
79 | self.assertTrue('CTF source and sink support' in self._plugin.description) | |
80 | ||
81 | def test_version(self): | |
82 | self.assertIsNone(self._plugin.version) | |
83 | ||
84 | def test_source_comp_classes_len(self): | |
85 | self.assertEqual(len(self._plugin.source_component_classes), 2) | |
86 | ||
87 | def test_source_comp_classes_getitem(self): | |
88 | self.assertEqual(self._plugin.source_component_classes['fs'].name, 'fs') | |
89 | ||
90 | def test_source_comp_classes_getitem_invalid(self): | |
91 | with self.assertRaises(KeyError): | |
92 | self._plugin.source_component_classes['lol'] | |
93 | ||
94 | def test_source_comp_classes_iter(self): | |
95 | plugins = {} | |
96 | ||
97 | for cc_name, cc in self._plugin.source_component_classes.items(): | |
98 | plugins[cc_name] = cc | |
99 | ||
100 | self.assertTrue('fs' in plugins) | |
101 | self.assertTrue('lttng-live' in plugins) | |
102 | self.assertEqual(plugins['fs'].name, 'fs') | |
103 | self.assertEqual(plugins['lttng-live'].name, 'lttng-live') | |
104 | ||
105 | def test_filter_comp_classes_len(self): | |
106 | plugin = bt2.find_plugin('utils') | |
107 | self.assertEqual(len(plugin.filter_component_classes), 2) | |
108 | ||
109 | def test_sink_comp_classes_len(self): | |
110 | self.assertEqual(len(self._plugin.sink_component_classes), 1) |