[Libosinfo] [libosinfo PATCH v2 09/12] test-os: Add test_duplication_helper()

Fabiano Fidêncio fidencio at redhat.com
Fri Jan 11 14:48:28 UTC 2019


By creating this, we can re-use it for testing Guest Features
duplication.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 tests/test-os.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/test-os.c b/tests/test-os.c
index 5ce3cfa..8c3a86c 100644
--- a/tests/test-os.c
+++ b/tests/test-os.c
@@ -550,17 +550,7 @@ static void check_duplicated_devices_cb(OsinfoProduct *product,
 }
 
 
-static void check_duplicated_devices(OsinfoOs *os)
-{
-    osinfo_product_foreach_related(OSINFO_PRODUCT(os),
-                                   OSINFO_PRODUCT_FOREACH_FLAG_DERIVES_FROM |
-                                   OSINFO_PRODUCT_FOREACH_FLAG_CLONES,
-                                   check_duplicated_devices_cb,
-                                   os);
-}
-
-
-static void test_devices_duplication(void)
+static void test_duplication_helper(void (check_duplicated_cb)(OsinfoProduct *, gpointer))
 {
     OsinfoLoader *loader = osinfo_loader_new();
     OsinfoDb *db = osinfo_loader_get_db(loader);
@@ -591,7 +581,11 @@ static void test_devices_duplication(void)
 
         for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(oslist)); i++) {
             OsinfoOs *os = OSINFO_OS(osinfo_list_get_nth(OSINFO_LIST(oslist), i));
-            check_duplicated_devices(os);
+            osinfo_product_foreach_related(OSINFO_PRODUCT(os),
+                                           OSINFO_PRODUCT_FOREACH_FLAG_DERIVES_FROM |
+                                           OSINFO_PRODUCT_FOREACH_FLAG_CLONES,
+                                           check_duplicated_cb,
+                                           os);
         }
 
         g_object_unref(filter);
@@ -604,6 +598,12 @@ static void test_devices_duplication(void)
 }
 
 
+static void test_devices_duplication(void)
+{
+    test_duplication_helper(check_duplicated_devices_cb);
+}
+
+
 static void
 devices_inheritance_basic_check(OsinfoDb *db,
                                 const gchar *os_id)
-- 
2.19.2




More information about the Libosinfo mailing list