summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2020-04-19 18:13:38 +0200
committerJens Georg <mail@jensge.org>2020-07-05 15:31:52 +0200
commitc83fff7eceb6ab54d00ed9aec27de63abe7ca486 (patch)
treecc235285c0377951129c1f5487717d5159564fca /tests
parent3689aa4463bebc66f95b427f2e2af351a97e38c3 (diff)
downloadrygel-c83fff7eceb6ab54d00ed9aec27de63abe7ca486.tar.gz
core: Add mutually exclusive plugin support
Add new, optional "Conflicts" keyword to the plugin meta-data which takes a list of names of other plugings that cannot be loaded together with this plugin. First plugin loaded wins Implements #155
Diffstat (limited to 'tests')
-rw-r--r--tests/data/plugin-loader/conflicts/librygel-no-conflict.so0
-rw-r--r--tests/data/plugin-loader/conflicts/librygel-tracker.so0
-rw-r--r--tests/data/plugin-loader/conflicts/librygel-tracker3.so0
-rw-r--r--tests/data/plugin-loader/conflicts/test.conf11
-rw-r--r--tests/meson.build13
-rw-r--r--tests/plugin-loader/rygel-plugin-loader-test.vala52
6 files changed, 76 insertions, 0 deletions
diff --git a/tests/data/plugin-loader/conflicts/librygel-no-conflict.so b/tests/data/plugin-loader/conflicts/librygel-no-conflict.so
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/data/plugin-loader/conflicts/librygel-no-conflict.so
diff --git a/tests/data/plugin-loader/conflicts/librygel-tracker.so b/tests/data/plugin-loader/conflicts/librygel-tracker.so
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/data/plugin-loader/conflicts/librygel-tracker.so
diff --git a/tests/data/plugin-loader/conflicts/librygel-tracker3.so b/tests/data/plugin-loader/conflicts/librygel-tracker3.so
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/data/plugin-loader/conflicts/librygel-tracker3.so
diff --git a/tests/data/plugin-loader/conflicts/test.conf b/tests/data/plugin-loader/conflicts/test.conf
new file mode 100644
index 00000000..85c6c8a4
--- /dev/null
+++ b/tests/data/plugin-loader/conflicts/test.conf
@@ -0,0 +1,11 @@
+[general]
+log-level = *:5
+
+[Tracker3]
+enabled = true
+
+[SomePlugin]
+enabled = true
+
+[Tracker]
+enabled = true
diff --git a/tests/meson.build b/tests/meson.build
index 9cc00e38..bb690457 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -66,6 +66,19 @@ http_time_seek_test = executable(
dependencies : [glib, soup]
)
+test('rygel-plugin-loader-test',
+ executable(
+ 'rygel-plugin-loader-test',
+ files(
+ 'plugin-loader/rygel-plugin-loader-test.vala'
+ ),
+ dependencies : [
+ rygel_core
+ ]
+ ),
+ workdir : meson.current_source_dir(),
+)
+
test('rygel-searchable-container-test', searchable_container_test)
test('rygel-object-creator-test', object_creator_test)
test('rygel-regression-test', regression_test)
diff --git a/tests/plugin-loader/rygel-plugin-loader-test.vala b/tests/plugin-loader/rygel-plugin-loader-test.vala
new file mode 100644
index 00000000..3f8db60d
--- /dev/null
+++ b/tests/plugin-loader/rygel-plugin-loader-test.vala
@@ -0,0 +1,52 @@
+class TestPluginLoader : Rygel.PluginLoader {
+ private string[] expected_plugins;
+ private string[] forbidden_plugins;
+ public string[] loaded_plugins;
+
+ public TestPluginLoader(string testset_location,
+ string[] expected_plugins,
+ string[] forbidden_plugins) {
+ Object(base_path : "data/plugin-loader/" + testset_location);
+ this.forbidden_plugins = forbidden_plugins;
+ this.expected_plugins = expected_plugins;
+ this.loaded_plugins = new string[0];
+ }
+
+ protected override bool load_module_from_file (File module) {
+ assert (module.get_basename () in expected_plugins);
+ assert (!(module.get_basename () in forbidden_plugins));
+
+ loaded_plugins += module.get_basename ();
+
+ // Just do nothing
+ return true;
+ }
+}
+
+void test_plugin_loader_conflict () {
+ try {
+ var config = new Rygel.UserConfig.with_paths (
+ "data/plugin-loader/conflicts/test.conf",
+ "data/plugin-loader/conflicts/test.conf");
+ Rygel.MetaConfig.register_configuration (config);
+ } catch (Error error) {
+ critical("%s", error.message);
+ assert_not_reached ();
+ }
+
+ var loader = new TestPluginLoader("conflicts",
+ {"librygel-tracker.so", "librygel-no-conflict.so"},
+ {"librygel-tracker3.so"});
+ loader.load_modules_sync (null);
+ assert (loader.loaded_plugins.length == 2);
+ assert ("librygel-tracker.so" in loader.loaded_plugins);
+ assert ("librygel-no-conflict.so" in loader.loaded_plugins);
+}
+
+int main (string[] args) {
+ Test.init (ref args);
+
+ Test.add_func ("/librygel-core/plugins/load-conflict",
+ test_plugin_loader_conflict);
+ return Test.run ();
+} \ No newline at end of file