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

Fabiano Fidêncio fidencio at redhat.com
Tue Apr 2 10:18:51 UTC 2019


Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 .../dbdata/os/libosinfo.org/test-db-media.xml | 13 +++++++++++
 tests/test-db.c                               | 22 +++++++++++++++++++
 2 files changed, 35 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..6d532d9 100644
--- a/tests/dbdata/os/libosinfo.org/test-db-media.xml
+++ b/tests/dbdata/os/libosinfo.org/test-db-media.xml
@@ -25,6 +25,19 @@
       </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>
+      </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 d1efc6c..abe8ad5 100644
--- a/tests/test-db.c
+++ b/tests/test-db.c
@@ -446,6 +446,27 @@ test_identify_media(void)
     g_assert_false(osinfo_db_identify_media(db, media));
     g_object_unref(media);
 
+    /* Matching against an "all" architecture */
+    media = osinfo_media_new("foo", "x86_64");
+    osinfo_entity_set_param(OSINFO_ENTITY(media),
+                            OSINFO_MEDIA_PROP_VOLUME_ID,
+                            "bootimg");
+    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);
 }
 
@@ -538,6 +559,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




More information about the Libosinfo mailing list