[gnome-software] trivial: Split out modalias to a new directory



commit fc53048b8aaeb13ff0e0fea30e26ceacf3e24d04
Author: Richard Hughes <richard hughsie com>
Date:   Tue Mar 7 13:51:29 2017 +0000

    trivial: Split out modalias to a new directory

 configure.ac                                |    1 +
 plugins/Makefile.am                         |   15 +---
 plugins/gs-self-test.c                      |   40 ----------
 plugins/modalias/Makefile.am                |   22 ++++++
 plugins/{ => modalias}/gs-plugin-modalias.c |    0
 plugins/modalias/gs-self-test.c             |  109 +++++++++++++++++++++++++++
 6 files changed, 136 insertions(+), 51 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8bc54ae..893efbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -490,6 +490,7 @@ plugins/dummy/Makefile
 plugins/external-appstream/Makefile
 plugins/fwupd/Makefile
 plugins/limba/Makefile
+plugins/modalias/Makefile
 plugins/odrs/Makefile
 plugins/ostree/Makefile
 plugins/packagekit/Makefile
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index a8b7907..50e6600 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -46,6 +46,10 @@ if HAVE_PACKAGEKIT
 SUBDIRS += packagekit
 endif
 
+if HAVE_GUDEV
+SUBDIRS += modalias
+endif
+
 AM_CPPFLAGS =                                          \
        -DDATADIR=\"$(datadir)\"                        \
        -DG_LOG_DOMAIN=\"GsPlugin\"                     \
@@ -67,10 +71,6 @@ if HAVE_WEBAPPS
 plugin_LTLIBRARIES += libgs_plugin_epiphany.la
 endif
 
-if HAVE_GUDEV
-plugin_LTLIBRARIES += libgs_plugin_modalias.la
-endif
-
 if HAVE_SHELL_EXTENSIONS
 plugin_LTLIBRARIES += libgs_plugin_shell-extensions.la
 endif
@@ -91,13 +91,6 @@ libgs_plugin_fedora_distro_upgrades_la_LIBADD = $(GS_PLUGIN_LIBS) $(JSON_GLIB_LI
 libgs_plugin_fedora_distro_upgrades_la_LDFLAGS = -module -avoid-version
 libgs_plugin_fedora_distro_upgrades_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(JSON_GLIB_CFLAGS) $(WARN_CFLAGS)
 
-if HAVE_GUDEV
-libgs_plugin_modalias_la_SOURCES = gs-plugin-modalias.c
-libgs_plugin_modalias_la_LIBADD = $(GS_PLUGIN_LIBS) $(GUDEV_LIBS)
-libgs_plugin_modalias_la_LDFLAGS = -module -avoid-version
-libgs_plugin_modalias_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(GUDEV_CFLAGS)
-endif
-
 libgs_plugin_fedora_tagger_usage_la_SOURCES = gs-plugin-fedora-tagger-usage.c
 libgs_plugin_fedora_tagger_usage_la_LIBADD = $(GS_PLUGIN_LIBS) $(SQLITE_LIBS)
 libgs_plugin_fedora_tagger_usage_la_LDFLAGS = -module -avoid-version
diff --git a/plugins/gs-self-test.c b/plugins/gs-self-test.c
index 9263bb0..a0d417c 100644
--- a/plugins/gs-self-test.c
+++ b/plugins/gs-self-test.c
@@ -26,34 +26,6 @@
 #include "gs-test.h"
 
 static void
-gs_plugin_loader_modalias_func (GsPluginLoader *plugin_loader)
-{
-       GsApp *app;
-       g_autofree gchar *menu_path = NULL;
-       g_autoptr(GError) error = NULL;
-       g_autoptr(GsAppList) list = NULL;
-
-       /* get search result based on addon keyword */
-       list = gs_plugin_loader_search (plugin_loader,
-                                       "colorhug2",
-                                       GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
-                                       GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
-                                       NULL,
-                                       &error);
-       gs_test_flush_main_context ();
-       g_assert_no_error (error);
-       g_assert (list != NULL);
-
-       /* make sure there is one entry, the parent app */
-       g_assert_cmpint (gs_app_list_length (list), ==, 1);
-       app = gs_app_list_index (list, 0);
-       g_assert_cmpstr (gs_app_get_id (app), ==, "com.hughski.ColorHug2.driver");
-       g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_DRIVER);
-       g_assert (gs_app_has_category (app, "Addons"));
-       g_assert (gs_app_has_category (app, "Drivers"));
-}
-
-static void
 gs_plugin_loader_webapps_func (GsPluginLoader *plugin_loader)
 {
        gboolean ret;
@@ -1192,7 +1164,6 @@ main (int argc, char **argv)
                "desktop-menu-path",
                "icons",
                "key-colors",
-               "modalias",
                "provenance",
                "provenance-license",
                "packagekit-local",
@@ -1223,14 +1194,6 @@ main (int argc, char **argv)
        g_assert (fn != NULL);
        xml = g_strdup_printf ("<?xml version=\"1.0\"?>\n"
                "<components version=\"0.9\">\n"
-               "  <component type=\"driver\">\n"
-               "    <id>com.hughski.ColorHug2.driver</id>\n"
-               "    <name>ColorHug2</name>\n"
-               "    <summary>ColorHug2 Colorimeter Driver</summary>\n"
-               "    <provides>\n"
-               "      <modalias>pci:*</modalias>\n"
-               "    </provides>\n"
-               "  </component>\n"
                "  <component type=\"desktop\">\n"
                "    <id>chiron.desktop</id>\n"
                "    <pkgname>chiron</pkgname>\n"
@@ -1322,9 +1285,6 @@ main (int argc, char **argv)
        g_test_add_data_func ("/gnome-software/plugin-loader{webapps}",
                              plugin_loader,
                              (GTestDataFunc) gs_plugin_loader_webapps_func);
-       g_test_add_data_func ("/gnome-software/plugin-loader{modalias}",
-                             plugin_loader,
-                             (GTestDataFunc) gs_plugin_loader_modalias_func);
 
        /* done last as it would otherwise try to do downloading in other
         * gs_plugin_file_to_app()-using tests */
diff --git a/plugins/modalias/Makefile.am b/plugins/modalias/Makefile.am
new file mode 100644
index 0000000..090f94f
--- /dev/null
+++ b/plugins/modalias/Makefile.am
@@ -0,0 +1,22 @@
+AM_CPPFLAGS =                                          \
+       -DTESTDATADIR=\""$(srcdir)"\"                   \
+       -DLOCALPLUGINDIR=\""$(builddir)/.libs"\"        \
+       -DLOCALPLUGINDIR_CORE=\""$(top_builddir)/plugins/core/.libs"\"
+
+plugindir = $(GS_PLUGIN_DIR)
+plugin_LTLIBRARIES = libgs_plugin_modalias.la
+
+libgs_plugin_modalias_la_SOURCES = gs-plugin-modalias.c
+libgs_plugin_modalias_la_LIBADD = $(GS_PLUGIN_LIBS) $(GUDEV_LIBS)
+libgs_plugin_modalias_la_LDFLAGS = -module -avoid-version
+libgs_plugin_modalias_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(GUDEV_CFLAGS)
+
+if ENABLE_TESTS
+check_PROGRAMS = gs-self-test
+gs_self_test_SOURCES = gs-self-test.c
+gs_self_test_LDADD = $(GS_PRIVATE_LIBS)
+gs_self_test_CFLAGS = $(GS_PRIVATE_CFLAGS)
+TESTS = gs-self-test
+endif
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/gs-plugin-modalias.c b/plugins/modalias/gs-plugin-modalias.c
similarity index 100%
rename from plugins/gs-plugin-modalias.c
rename to plugins/modalias/gs-plugin-modalias.c
diff --git a/plugins/modalias/gs-self-test.c b/plugins/modalias/gs-self-test.c
new file mode 100644
index 0000000..d3408a8
--- /dev/null
+++ b/plugins/modalias/gs-self-test.c
@@ -0,0 +1,109 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2013-2017 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include "gnome-software-private.h"
+
+#include "gs-test.h"
+
+static void
+gs_plugin_loader_modalias_func (GsPluginLoader *plugin_loader)
+{
+       GsApp *app;
+       g_autofree gchar *menu_path = NULL;
+       g_autoptr(GError) error = NULL;
+       g_autoptr(GsAppList) list = NULL;
+
+       /* get search result based on addon keyword */
+       list = gs_plugin_loader_search (plugin_loader,
+                                       "colorhug2",
+                                       GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
+                                       GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
+                                       NULL,
+                                       &error);
+       gs_test_flush_main_context ();
+       g_assert_no_error (error);
+       g_assert (list != NULL);
+
+       /* make sure there is one entry, the parent app */
+       g_assert_cmpint (gs_app_list_length (list), ==, 1);
+       app = gs_app_list_index (list, 0);
+       g_assert_cmpstr (gs_app_get_id (app), ==, "com.hughski.ColorHug2.driver");
+       g_assert_cmpint (gs_app_get_kind (app), ==, AS_APP_KIND_DRIVER);
+       g_assert (gs_app_has_category (app, "Addons"));
+       g_assert (gs_app_has_category (app, "Drivers"));
+}
+
+int
+main (int argc, char **argv)
+{
+       gboolean ret;
+       g_autofree gchar *xml = NULL;
+       g_autoptr(GError) error = NULL;
+       g_autoptr(GsPluginLoader) plugin_loader = NULL;
+       const gchar *whitelist[] = {
+               "appstream",
+               "modalias",
+               NULL
+       };
+
+       g_test_init (&argc, &argv, NULL);
+       g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+
+       xml = g_strdup_printf ("<?xml version=\"1.0\"?>\n"
+               "<components version=\"0.9\">\n"
+               "  <component type=\"driver\">\n"
+               "    <id>com.hughski.ColorHug2.driver</id>\n"
+               "    <name>ColorHug2</name>\n"
+               "    <summary>ColorHug2 Colorimeter Driver</summary>\n"
+               "    <provides>\n"
+               "      <modalias>pci:*</modalias>\n"
+               "    </provides>\n"
+               "  </component>\n"
+               "</components>\n");
+       g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
+
+       /* only critical and error are fatal */
+       g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
+
+       /* we can only load this once per process */
+       plugin_loader = gs_plugin_loader_new ();
+       gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR);
+       gs_plugin_loader_add_location (plugin_loader, LOCALPLUGINDIR_CORE);
+       ret = gs_plugin_loader_setup (plugin_loader,
+                                     (gchar**) whitelist,
+                                     NULL,
+                                     GS_PLUGIN_FAILURE_FLAGS_NONE,
+                                     NULL,
+                                     &error);
+       g_assert_no_error (error);
+       g_assert (ret);
+
+       /* plugin tests go here */
+       g_test_add_data_func ("/gnome-software/plugin-loader{modalias}",
+                             plugin_loader,
+                             (GTestDataFunc) gs_plugin_loader_modalias_func);
+
+       return g_test_run ();
+}
+
+/* vim: set noexpandtab: */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]