Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- .../test-os-features-removed-1.xml | 14 +++ .../test-os-features-removed-2-clone.xml | 10 ++ .../test-os-features-removed-2.xml | 10 ++ .../test-os-features-removed-3.xml | 15 +++ .../test-os-features-removed-4-clone.xml | 10 ++ .../test-os-features-removed-4.xml | 10 ++ tests/test-os.c | 95 +++++++++++++++++++ 7 files changed, 164 insertions(+) create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-removed-1.xml create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-removed-2-clone.xml create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-removed-2.xml create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-removed-3.xml create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-removed-4-clone.xml create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-removed-4.xml diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-removed-1.xml b/tests/dbdata/os/libosinfo.org/test-os-features-removed-1.xml new file mode 100644 index 0000000..d2c7806 --- /dev/null +++ b/tests/dbdata/os/libosinfo.org/test-os-features-removed-1.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<libosinfo version="0.0.1"> + <os id="http://libosinfo.org/test/os/features/removed/1"> + <short-id>features-removed-1</short-id> + <name>Features Removed 1</name> + <vendor>libosinfo.org</vendor> + <family>test</family> + <derives-from id="http://libosinfo.org/test/os/features/basic/1"/> + + <features arch="x86_64"> + <feature supported="false">cpu-hotplug</feature> + </features> + </os> +</libosinfo> diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-removed-2-clone.xml b/tests/dbdata/os/libosinfo.org/test-os-features-removed-2-clone.xml new file mode 100644 index 0000000..d6d2088 --- /dev/null +++ b/tests/dbdata/os/libosinfo.org/test-os-features-removed-2-clone.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<libosinfo version="0.0.1"> + <os id="http://libosinfo.org/test/os/features/removed/2-clone"> + <short-id>features-removed-2-clone</short-id> + <name>Features Removed 2 Clone</name> + <vendor>libosinfo.org</vendor> + <family>test</family> + <clones id="http://libosinfo.org/test/os/features/removed/2"/> + </os> +</libosinfo> diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-removed-2.xml b/tests/dbdata/os/libosinfo.org/test-os-features-removed-2.xml new file mode 100644 index 0000000..7939e98 --- /dev/null +++ b/tests/dbdata/os/libosinfo.org/test-os-features-removed-2.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<libosinfo version="0.0.1"> + <os id="http://libosinfo.org/test/os/features/removed/2"> + <short-id>features-removed-2</short-id> + <name>Features Removed 2</name> + <vendor>libosinfo.org</vendor> + <family>test</family> + <derives-from id="http://libosinfo.org/test/os/features/removed/1"/> + </os> +</libosinfo> diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-removed-3.xml b/tests/dbdata/os/libosinfo.org/test-os-features-removed-3.xml new file mode 100644 index 0000000..c433945 --- /dev/null +++ b/tests/dbdata/os/libosinfo.org/test-os-features-removed-3.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<libosinfo version="0.0.1"> + <os id="http://libosinfo.org/test/os/features/removed/3"> + <short-id>features-removed-3</short-id> + <name>Features Removed 3</name> + <vendor>libosinfo.org</vendor> + <family>test</family> + <derives-from id="http://libosinfo.org/test/os/features/removed/2"/> + + <features arch="x86_64"> + <feature>cpu-hotplug</feature> + </features> + + </os> +</libosinfo> diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-removed-4-clone.xml b/tests/dbdata/os/libosinfo.org/test-os-features-removed-4-clone.xml new file mode 100644 index 0000000..cb638e6 --- /dev/null +++ b/tests/dbdata/os/libosinfo.org/test-os-features-removed-4-clone.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<libosinfo version="0.0.1"> + <os id="http://libosinfo.org/test/os/features/removed/4-clone"> + <short-id>features-removed-4-clone</short-id> + <name>Features Removed 4 Clone</name> + <vendor>libosinfo.org</vendor> + <family>test</family> + <clones id="http://libosinfo.org/test/os/features/removed/4"/> + </os> +</libosinfo> diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-removed-4.xml b/tests/dbdata/os/libosinfo.org/test-os-features-removed-4.xml new file mode 100644 index 0000000..7f5b7cb --- /dev/null +++ b/tests/dbdata/os/libosinfo.org/test-os-features-removed-4.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<libosinfo version="0.0.1"> + <os id="http://libosinfo.org/test/os/features/removed/4"> + <short-id>features-removed-4</short-id> + <name>Features Removed 4</name> + <vendor>libosinfo.org</vendor> + <family>test</family> + <derives-from id="http://libosinfo.org/test/os/features/removed/3"/> + </os> +</libosinfo> diff --git a/tests/test-os.c b/tests/test-os.c index 851c99e..0aa6715 100644 --- a/tests/test-os.c +++ b/tests/test-os.c @@ -832,6 +832,99 @@ test_devices_inheritance_removal(void) } +static void +features_inheritance_removal_check_features(OsinfoDb *db, + const gchar *os_id, + gint feature_list_len) +{ + OsinfoOs *os; + OsinfoFeatureList *feature_list; + + g_test_message("Testing \"%s\"\n", os_id); + + os = osinfo_db_get_os(db, os_id); + g_assert(OSINFO_IS_OS(os)); + + feature_list = osinfo_os_get_feature_list(os, "x86_64"); + g_assert_cmpint(osinfo_list_get_length(OSINFO_LIST(feature_list)), ==, feature_list_len); + g_object_unref(feature_list); +} + + +static void +test_features_inheritance_removal(void) +{ + OsinfoLoader *loader = osinfo_loader_new(); + OsinfoDb *db; + GError *error = NULL; + + osinfo_loader_process_path(loader, SRCDIR "/tests/dbdata", &error); + g_assert_no_error(error); + db = g_object_ref(osinfo_loader_get_db(loader)); + g_object_unref(loader); + + /* + * "http://libosinfo.org/test/os/features/basic/1 has one two features set + */ + features_inheritance_removal_check_features(db, + "http://libosinfo.org/test/os/features/basic/1", + 2); + + /* + * http://libosinfo.org/test/os/features/removed/1 derives-from + * http://libosinfo.org/test/os/features/basic/1 ... + * And the one feature is marked as removed + */ + features_inheritance_removal_check_features(db, + "http://libosinfo.org/test/os/features/removed/1", + 1); + + /* + * http://libosinfo.org/test/os/features/removed/2 derives-from + * http://libosinfo.org/test/os/features/removed/1 + */ + features_inheritance_removal_check_features(db, + "http://libosinfo.org/test/os/features/removed/2", + 1); + + /* + * http://libosinfo.org/test/os/features/removed/2-clone clones + * http://libosinfo.org/test/os/features/removed/2 + */ + features_inheritance_removal_check_features(db, + "http://libosinfo.org/test/os/features/removed/2-clone", + 1); + + /* + * http://libosinfo.org/test/os/features/removed/3 derives-from + * http://libosinfo.org/test/os/features/removed/2 + * And the feature is not marked as removed anymore + */ + features_inheritance_removal_check_features(db, + "http://libosinfo.org/test/os/features/removed/3", + 2); + + /* + * http://libosinfo.org/test/os/features/removed/4 derives-from + * http://libosinfo.org/test/os/features/removed/3 + */ + features_inheritance_removal_check_features(db, + "http://libosinfo.org/test/os/features/removed/4", + 2); + + + /* + * http://libosinfo.org/test/os/features/removed/4-clone clones + * http://libosinfo.org/test/os/features/removed/4 + */ + features_inheritance_removal_check_features(db, + "http://libosinfo.org/test/os/features/removed/4-clone", + 2); + + g_object_unref(db); +} + + static void check_resources(OsinfoDb *db, const gchar *os_id, @@ -1036,6 +1129,8 @@ main(int argc, char *argv[]) g_test_add_func("/os/features", test_features); g_test_add_func("/os/features/inheritance/basic", test_features_inheritance_basic); + g_test_add_func("/os/features/inheritance/removal", + test_features_inheritance_removal); g_test_add_func("/os/resources/minimum_recommended_maximum", test_resources_minimum_recommended_maximum); g_test_add_func("/os/resources/uniqueness", test_resources_uniqueness); -- 2.19.2 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo