[Libosinfo] [libosinfo PATCH 28/31] test-os: Add test_duplication_helper()

Fabiano Fidêncio fidencio at redhat.com
Fri Nov 23 10:15:17 UTC 2018


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 b154e94..a3b4cc9 100644
--- a/tests/test-os.c
+++ b/tests/test-os.c
@@ -523,17 +523,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);
@@ -564,7 +554,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);
@@ -577,6 +571,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.1




More information about the Libosinfo mailing list