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

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

 



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

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 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

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux