[Libosinfo] [libosinfo PATCH 2/3] test-os: Cover osinfo_tree_has_treeinfo()

Fabiano Fidêncio fidencio at redhat.com
Mon Dec 10 12:37:36 UTC 2018


Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 .../dbdata/os/fedoraproject.org/fedora-16.xml |  4 +++
 tests/test-os.c                               | 29 ++++++++++++++-----
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/tests/dbdata/os/fedoraproject.org/fedora-16.xml b/tests/dbdata/os/fedoraproject.org/fedora-16.xml
index c67ce23..758c45a 100644
--- a/tests/dbdata/os/fedoraproject.org/fedora-16.xml
+++ b/tests/dbdata/os/fedoraproject.org/fedora-16.xml
@@ -28,5 +28,9 @@
         <arch>i386</arch>
       </treeinfo>
     </tree>
+
+    <tree arch="x86_64">
+      <url>http://archive.fedoraproject.org/pub/archive/fedora/linux/releases/16/Fedora/x86_64/os/</url>
+    </tree>
   </os>
 </libosinfo>
diff --git a/tests/test-os.c b/tests/test-os.c
index 1756e59..7c0a198 100644
--- a/tests/test-os.c
+++ b/tests/test-os.c
@@ -70,6 +70,8 @@ test_loader(void)
     OsinfoTreeList *treelist;
     OsinfoTree *tree;
     GError *error = NULL;
+    gsize i = 0;
+    gint treelist_len;
     const char *str;
 
     loader = osinfo_loader_new();
@@ -131,14 +133,25 @@ test_loader(void)
     str = osinfo_product_get_short_id(OSINFO_PRODUCT(os));
     g_assert_cmpstr(str, ==, "fedora16");
     treelist = osinfo_os_get_tree_list(os);
-    g_assert_cmpint(osinfo_list_get_length(OSINFO_LIST(treelist)), ==, 1);
-    tree = OSINFO_TREE(osinfo_list_get_nth(OSINFO_LIST(treelist), 0));
-    str = osinfo_tree_get_treeinfo_family(tree);
-    g_assert_cmpstr(str, ==, "Fedora");
-    str = osinfo_tree_get_treeinfo_version(tree);
-    g_assert_cmpstr(str, ==, "16");
-    str = osinfo_tree_get_treeinfo_arch(tree);
-    g_assert_cmpstr(str, ==, "i386");
+    treelist_len = osinfo_list_get_length(OSINFO_LIST(treelist));
+    g_assert_cmpint(treelist_len, ==, 2);
+
+    for (i = 0; i < treelist_len; i++) {
+        tree = OSINFO_TREE(osinfo_list_get_nth(OSINFO_LIST(treelist), i));
+
+        str = osinfo_tree_get_architecture(tree);
+        if (g_str_equal(str, "i686")) {
+            g_assert_true(osinfo_tree_has_treeinfo(tree));
+            str = osinfo_tree_get_treeinfo_family(tree);
+            g_assert_cmpstr(str, ==, "Fedora");
+            str = osinfo_tree_get_treeinfo_version(tree);
+            g_assert_cmpstr(str, ==, "16");
+            str = osinfo_tree_get_treeinfo_arch(tree);
+            g_assert_cmpstr(str, ==, "i386");
+        } else {
+            g_assert_false(osinfo_tree_has_treeinfo(tree));
+        }
+    }
 
     g_object_unref(loader);
 }
-- 
2.19.1




More information about the Libosinfo mailing list