gplugin/gplugin

309964817aa5
Parents a7cb44804c3b
Children e8f3d3ed4fad
Cleaned up a lot in the versioned dependencies test, still haven't found the cause of the leak
--- a/gplugin/tests/test-versioned-dependencies.c Thu Mar 12 23:19:23 2020 -0500
+++ b/gplugin/tests/test-versioned-dependencies.c Thu Mar 12 23:32:52 2020 -0500
@@ -15,24 +15,17 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdlib.h>
-
#include <glib.h>
#include <gplugin.h>
-#include <gplugin-native.h>
/******************************************************************************
* Helpers
*****************************************************************************/
static void
-_test_plugin_load_and_has_dependent(
- GPluginPlugin *dependent,
- G_GNUC_UNUSED const gchar *id)
+_test_plugin_loaded(GPluginPlugin *dependent, const gchar *id)
{
GPluginPlugin *plugin = NULL;
- GSList *deps = NULL, *l = NULL;
- gboolean found = FALSE;
plugin = gplugin_manager_find_plugin(id);
g_assert_cmpint(
@@ -40,19 +33,6 @@
==,
GPLUGIN_PLUGIN_STATE_LOADED);
- deps = gplugin_manager_get_plugin_dependencies(plugin, NULL);
- if(deps != NULL) {
- for(l = deps; l; l = l->next) {
- if(l->data == dependent) {
- found = TRUE;
- }
- }
-
- g_slist_free_full(deps, g_object_unref);
-
- g_assert_true(found);
- }
-
g_object_unref(G_OBJECT(plugin));
}
@@ -64,8 +44,10 @@
{
GPluginPlugin *plugin = NULL;
GError *error = NULL;
+ gboolean ret = FALSE;
- gplugin_manager_remove_paths();
+ gplugin_init();
+
gplugin_manager_append_path(TEST_VERSIONED_DEPENDENCY_DIR);
gplugin_manager_refresh();
@@ -73,26 +55,31 @@
g_assert_nonnull(plugin);
g_assert_true(GPLUGIN_IS_PLUGIN(plugin));
- gplugin_manager_load_plugin(plugin, &error);
+ ret = gplugin_manager_load_plugin(plugin, &error);
+
+ g_assert_true(ret);
g_assert_no_error(error);
g_assert_cmpint(
gplugin_plugin_get_state(plugin),
==,
GPLUGIN_PLUGIN_STATE_LOADED);
- g_object_unref(G_OBJECT(plugin));
/* now make sure each dependent plugin that's available was loaded */
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-no-version");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-exact1");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-exact2");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-greater");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-greater-equal");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-less");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/test-less-equal");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/bar");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/baz");
- _test_plugin_load_and_has_dependent(plugin, "gplugin/fez");
+ _test_plugin_loaded(plugin, "gplugin/test-no-version");
+ _test_plugin_loaded(plugin, "gplugin/test-exact1");
+ _test_plugin_loaded(plugin, "gplugin/test-exact2");
+ _test_plugin_loaded(plugin, "gplugin/test-greater");
+ _test_plugin_loaded(plugin, "gplugin/test-greater-equal");
+ _test_plugin_loaded(plugin, "gplugin/test-less");
+ _test_plugin_loaded(plugin, "gplugin/test-less-equal");
+ _test_plugin_loaded(plugin, "gplugin/bar");
+ _test_plugin_loaded(plugin, "gplugin/baz");
+ _test_plugin_loaded(plugin, "gplugin/fez");
+
+ g_object_unref(G_OBJECT(plugin));
+
+ gplugin_uninit();
}
/******************************************************************************
@@ -101,20 +88,12 @@
gint
main(gint argc, gchar **argv)
{
- gint r = 0;
-
g_test_init(&argc, &argv, NULL);
- gplugin_init();
-
/* test the load on query flag */
g_test_add_func(
"/dependent-versions/super-dependent",
test_load_with_dependencies);
- r = g_test_run();
-
- gplugin_uninit();
-
- return r;
+ return g_test_run();
}