qulogic/gplugin

Merged in feature/genie-tests (pull request #56)
develop
2020-02-19, Gary Kramlich
e570766a9abc
Merged in feature/genie-tests (pull request #56)

Feature/genie tests

Approved-by: Elliott Sales de Andrade
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/reference/genie.xml Wed Feb 19 04:11:26 2020 +0000
@@ -0,0 +1,70 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<chapter id="chapter-genie">
+ <title>Genie Plugins</title>
+
+ <warning>
+ <para>
+ You <emphasis role="strong">MUST</emphasis> have the Vala bindings
+ installed on your system for this to work. They are built by the
+ default GPlugin build.
+ </para>
+ </warning>
+
+ <simplesect>
+ <title>Example Genie Plugin</title>
+
+ <para>
+ Like all plugins in GPlugin, Genie plugins must also implement
+ the <code>gplugin_query</code>, <code>gplugin_load</code>, and
+ <code>gplugin_unload</code> functions.
+ </para>
+
+ <para>
+ Due to the way <code>GPlugin.PluginInfo</code> info works, you must
+ subclass it and set your values in the new constructor.
+ </para>
+
+ <para>
+ The following is a basic Genie plugin.
+ </para>
+
+ <informalexample><programlisting>
+ uses GPlugin
+
+ class BasicPluginInfo : GPlugin.PluginInfo
+ construct()
+ authors : array of string = {"author1"}
+
+ Object(
+ id: "gplugin/genie-basic-plugin",
+ abi_version: 0x01020304,
+ name: "basic plugin",
+ authors: authors,
+ category: "test",
+ version: "version",
+ license_id: "license",
+ summary: "summary",
+ website: "website",
+ description: "description"
+ )
+
+ def gplugin_query(out error : Error) : GPlugin.PluginInfo
+ error = null
+
+ return new BasicPluginInfo()
+
+ def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return true
+
+ def gplugin_unload(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return true
+ </programlisting></informalexample>
+ </simplesect>
+</chapter>
--- a/gplugin/reference/gplugin-docs.xml Wed Feb 19 03:51:27 2020 +0000
+++ b/gplugin/reference/gplugin-docs.xml Wed Feb 19 04:11:26 2020 +0000
@@ -23,8 +23,9 @@
<title>Tutorials</title>
<xi:include href="embedding.xml"/>
+ <xi:include href="genie.xml"/>
+ <xi:include href="lua.xml"/>
<xi:include href="native-plugins.xml"/>
- <xi:include href="lua.xml"/>
<xi:include href="python.xml"/>
<xi:include href="vala.xml"/>
</part>
--- a/gplugin/reference/meson.build Wed Feb 19 03:51:27 2020 +0000
+++ b/gplugin/reference/meson.build Wed Feb 19 04:11:26 2020 +0000
@@ -26,6 +26,7 @@
content_files = [
'embedding.xml',
+ 'genie.xml',
'lua.xml',
'native-plugins.xml',
'python.xml',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/genie-plugins/basic.gs Wed Feb 19 04:11:26 2020 +0000
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+uses GPlugin
+
+class BasicPluginInfo : GPlugin.PluginInfo
+ construct()
+ authors : array of string = {"author1"}
+
+ Object(
+ id: "gplugin/genie-basic-plugin",
+ abi_version: 0x01020304,
+ name: "basic plugin",
+ authors: authors,
+ category: "test",
+ version: "version",
+ license_id: "license",
+ summary: "summary",
+ website: "website",
+ description: "description"
+ )
+
+def gplugin_query(out error : Error) : GPlugin.PluginInfo
+ error = null
+
+ return new BasicPluginInfo()
+
+def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return true
+
+def gplugin_unload(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return true
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/genie-plugins/dependent.gs Wed Feb 19 04:11:26 2020 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+uses GPlugin;
+
+class DependentPluginInfo : GPlugin.PluginInfo
+ construct()
+ dependencies : array of string = {"dependency1", "dependency2"}
+
+ Object(
+ id: "gplugin/genie-dependent-plugin",
+ dependencies: dependencies
+ )
+
+def gplugin_query(out error : Error) : GPlugin.PluginInfo
+ error = null
+
+ return new DependentPluginInfo()
+
+def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return true
+
+def gplugin_unload(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return false
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/genie-plugins/load-exception.gs Wed Feb 19 04:11:26 2020 +0000
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+uses GPlugin
+
+class LoadExceptionPluginInfo : GPlugin.PluginInfo
+ construct ()
+ Object(
+ id: "gplugin/genie-load-exception"
+ )
+
+def gplugin_query(out error : Error) : GPlugin.PluginInfo
+ error = null
+
+ return new LoadExceptionPluginInfo()
+
+def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = new Error(Quark.from_string("gplugin"), 0, "explode")
+
+ return false
+
+def gplugin_unload(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return true
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/genie-plugins/load-failed.gs Wed Feb 19 04:11:26 2020 +0000
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+uses GPlugin
+
+class LoadFailedPluginInfo : GPlugin.PluginInfo
+ construct ()
+ Object(
+ id: "gplugin/genie-load-failed"
+ )
+
+def gplugin_query(out error : Error) : GPlugin.PluginInfo
+ error = null
+
+ return new LoadFailedPluginInfo()
+
+def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return false
+
+def gplugin_unload(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return true
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/genie-plugins/meson.build Wed Feb 19 04:11:26 2020 +0000
@@ -0,0 +1,17 @@
+if get_option('vapi')
+ shared_library('genie-basic-plugin', 'basic.gs',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('genie-dependent-plugin', 'dependent.gs',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('load-exception-plugin', 'load-exception.gs',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('load-failed-plugin', 'load-failed.gs',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('unload-failed-plugin', 'unload-failed.gs',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+endif # vapi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/genie-plugins/unload-failed.gs Wed Feb 19 04:11:26 2020 +0000
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+uses GPlugin
+
+class UnloadFailedPluginInfo : GPlugin.PluginInfo
+ construct()
+ Object(
+ id: "gplugin/genie-unload-failed"
+ )
+
+def gplugin_query(out error : Error) : GPlugin.PluginInfo
+ error = null
+
+ return new UnloadFailedPluginInfo()
+
+def gplugin_load(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return true
+
+def gplugin_unload(plugin : GPlugin.Plugin, out error : Error) : bool
+ error = null
+
+ return false
--- a/vala/tests/meson.build Wed Feb 19 03:51:27 2020 +0000
+++ b/vala/tests/meson.build Wed Feb 19 04:11:26 2020 +0000
@@ -9,6 +9,16 @@
dependencies : [GLIB, GOBJECT, gplugin_dep])
test('Vala loading', e)
+e = executable('test-genie-loading', 'test-genie-loading.c',
+ include_directories : include_directories('.'),
+ c_args : [
+ '-DGENIE_PLUGIN_DIR="@0@/genie-plugins"'.format(meson.current_build_dir()),
+ ],
+ link_with : gplugin_loader_tests,
+ dependencies : [GLIB, GOBJECT, gplugin_dep])
+test('Genie loading', e)
+
+subdir('genie-plugins')
subdir('plugins')
endif # vapi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/test-genie-loading.c Wed Feb 19 04:11:26 2020 +0000
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <gplugin.h>
+
+#include <gplugin/gplugin-loader-tests.h>
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+gint
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ gplugin_loader_tests_main(NULL, GENIE_PLUGIN_DIR, "genie");
+
+ return g_test_run();
+}