tests/bindings/python/Makefile
tests/bindings/python/bt2/Makefile
tests/plugins/Makefile
+ tests/python-plugin-provider/Makefile
extras/Makefile
extras/valgrind/Makefile
plugins/Makefile
[AC_CONFIG_FILES([tests/bindings/python/bt2/testall.sh], [chmod +x tests/bindings/python/bt2/testall.sh])]
)
+AS_IF([test "x$enable_python_plugins" = "xyes"],
+ [AC_CONFIG_FILES([tests/python-plugin-provider/test.sh], [chmod +x tests/python-plugin-provider/test.sh])]
+)
+
AC_OUTPUT
#
if !ENABLE_BUILT_IN_PLUGINS
SUBDIRS += plugins
endif
+
+if ENABLE_PYTHON_PLUGINS
+SUBDIRS += python-plugin-provider
+endif
--- /dev/null
+htmlcov
+.coverage
+test.sh
--- /dev/null
+check_SCRIPTS = test.sh
+EXTRA_DIST = \
+ $(check_SCRIPTS) \
+ test_python_plugin_provider.py \
+ bt_plugin_test_python_plugin_provider.py
+
+LOG_DRIVER_FLAGS='--merge'
+LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/config/tap-driver.sh
+
+if ENABLE_PYTHON_BINDINGS
+TESTS = test.sh
+endif
--- /dev/null
+import bt2
+
+
+class MyIter(bt2._UserNotificationIterator):
+ pass
+
+
+@bt2.plugin_component_class
+class MySource(bt2._UserSourceComponent,
+ notification_iterator_class=MyIter):
+ pass
+
+
+@bt2.plugin_component_class
+class MyFilter(bt2._UserFilterComponent,
+ notification_iterator_class=MyIter):
+ pass
+
+
+@bt2.plugin_component_class
+class MySink(bt2._UserSinkComponent):
+ def _consume(self):
+ pass
+
+
+bt2.register_plugin(__name__, 'sparkling', author='Philippe Proulx',
+ description='A delicious plugin.',
+ version=(1, 2, 3, 'EXTRA'),
+ license='MIT')
--- /dev/null
+#!/bin/sh
+
+export PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH="@abs_top_srcdir@/tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py"
+export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:@abs_top_builddir@/python-plugin-provider:@abs_top_builddir@/python-plugin-provider/.libs"
+PYTHON_BUILD_DIR="@abs_top_builddir@/bindings/python"
+BT2_NATIVE_LIBS_DIR="@abs_top_builddir@/bindings/python/bt2/.libs"
+TESTS_UTILS_PYTHON_DIR="@abs_top_srcdir@/tests/utils/python"
+TESTRUNNER_PY="@abs_top_srcdir@/tests/utils/python/testrunner.py"
+THIS_DIR="@abs_top_srcdir@/tests/python-plugin-provider"
+
+PYTHONPATH="$PYTHON_BUILD_DIR:$BT2_NATIVE_LIBS_DIR:$TESTS_UTILS_PYTHON_DIR" \
+ "@PYTHON@" "$TESTRUNNER_PY" "$THIS_DIR"
+exit $?
--- /dev/null
+import unittest
+import bt2
+import os
+
+
+class PythonPluginProviderTestCase(unittest.TestCase):
+ def test_python_plugin_provider(self):
+ pset = bt2.find_plugins(os.environ['PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH'])
+ self.assertEqual(len(pset), 1)
+ plugin = pset[0]
+ self.assertEqual(plugin.name, 'sparkling')
+ self.assertEqual(plugin.author, 'Philippe Proulx')
+ self.assertEqual(plugin.description, 'A delicious plugin.')
+ self.assertEqual(plugin.version.major, 1)
+ self.assertEqual(plugin.version.minor, 2)
+ self.assertEqual(plugin.version.patch, 3)
+ self.assertEqual(plugin.version.extra, 'EXTRA')
+ self.assertEqual(plugin.license, 'MIT')
+ self.assertEqual(len(plugin.source_component_classes), 1)
+ self.assertEqual(len(plugin.filter_component_classes), 1)
+ self.assertEqual(len(plugin.sink_component_classes), 1)
+ self.assertEqual(plugin.source_component_classes['MySource'].name, 'MySource')
+ self.assertEqual(plugin.filter_component_classes['MyFilter'].name, 'MyFilter')
+ self.assertEqual(plugin.sink_component_classes['MySink'].name, 'MySink')