https://gitlab.com/libosinfo/libosinfo/issues/20 Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- .../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..3a7f2cc 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="unknown"> + <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 ac7f9c8..05aa2ae 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), ==, "unknown"); + 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 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo