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

[Libosinfo] [libosinfo PATCH v2 8/8] test-db: Add test to cover identifying a media with "unknown" arch



Signed-off-by: Fabiano Fidêncio <fidencio redhat com>
---
 .../dbdata/os/libosinfo.org/test-db-media.xml | 14 +++++++++++
 tests/test-db.c                               | 25 +++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/tests/dbdata/os/libosinfo.org/test-db-media.xml b/tests/dbdata/os/libosinfo.org/test-db-media.xml
index 04badfd..89de6a4 100644
--- a/tests/dbdata/os/libosinfo.org/test-db-media.xml
+++ b/tests/dbdata/os/libosinfo.org/test-db-media.xml
@@ -25,6 +25,20 @@
       </installer>
     </media>
 
+    <media arch="i686">
+      <iso>
+        <volume-id>bootimg</volume-id>
+        <system-id>LINUX</system-id>
+      </iso>
+    </media>
+
+    <media arch="all">
+      <iso>
+        <volume-id>bootimg</volume-id>
+        <system-id>LINUX</system-id>
+      </iso>
+    </media>
+
     <installer>
       <script id="http://example.com/libosinfo/test-install-script"/>
     </installer>
diff --git a/tests/test-db.c b/tests/test-db.c
index d5e8b49..9790140 100644
--- a/tests/test-db.c
+++ b/tests/test-db.c
@@ -446,6 +446,30 @@ test_identify_media(void)
     g_assert_false(osinfo_db_identify_media(db, media));
     g_object_unref(media);
 
+    /* Matching against an "unknown" architecture */
+    media = osinfo_media_new("foo", "x86_64");
+    osinfo_entity_set_param(OSINFO_ENTITY(media),
+                            OSINFO_MEDIA_PROP_VOLUME_ID,
+                            "bootimg");
+    osinfo_entity_set_param(OSINFO_ENTITY(media),
+                            OSINFO_MEDIA_PROP_SYSTEM_ID,
+                            "LINUX");
+    g_assert_true(osinfo_db_identify_media(db, media));
+    g_assert_cmpstr(osinfo_media_get_architecture(media), ==, "all");
+    g_object_unref(media);
+
+    /* Matching against a known architecture, which has to have precendence */
+    media = osinfo_media_new("foo", "i686");
+    osinfo_entity_set_param(OSINFO_ENTITY(media),
+                            OSINFO_MEDIA_PROP_VOLUME_ID,
+                            "bootimg");
+    osinfo_entity_set_param(OSINFO_ENTITY(media),
+                            OSINFO_MEDIA_PROP_SYSTEM_ID,
+                            "LINUX");
+    g_assert_true(osinfo_db_identify_media(db, media));
+    g_assert_cmpstr(osinfo_media_get_architecture(media), ==, "i686");
+    g_object_unref(media);
+
     g_object_unref(loader);
 }
 
@@ -533,6 +557,7 @@ main(int argc, char *argv[])
     osinfo_install_script_get_type();
     osinfo_install_scriptlist_get_type();
     osinfo_tree_get_type();
+    osinfo_media_get_type();
 
     return g_test_run();
 }
-- 
2.20.1


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