summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2018-12-10 13:11:36 +0100
committerFabiano FidĂȘncio <fidencio@redhat.com>2018-12-10 15:11:08 +0100
commita3e878f92259375b5621c31e182e7aa5c65e2f2f (patch)
tree38f7d265cd6959ffac88381861200c6c207f3a44
parenteb53f8d6d99a85e651816e8765cdb6c9df5b48e7 (diff)
downloadlibosinfo-a3e878f92259375b5621c31e182e7aa5c65e2f2f.tar.gz
test-os: Cover osinfo_tree_has_treeinfo()
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com> Reviewed-by: Christophe Fergeau <cfergeau@redhat.com>
-rw-r--r--tests/dbdata/os/fedoraproject.org/fedora-16.xml4
-rw-r--r--tests/test-os.c29
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 8d2623c..45598bb 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);
}