[Libosinfo] [libosinfo PATCH 12/12] test-os: Add test_features_inheritance_removal()

Fabiano Fidêncio fidencio at redhat.com
Fri Jan 11 14:49:29 UTC 2019


Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 .../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            | 14 +++
 .../test-os-features-removed-4-clone.xml      | 10 ++
 .../test-os-features-removed-4.xml            | 10 ++
 tests/test-os.c                               | 95 +++++++++++++++++++
 7 files changed, 163 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..44f6cce
--- /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>
+      <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..b582739
--- /dev/null
+++ b/tests/dbdata/os/libosinfo.org/test-os-features-removed-3.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/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>
+      <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 4e8694a..14642e4 100644
--- a/tests/test-os.c
+++ b/tests/test-os.c
@@ -898,6 +898,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);
+    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 feature set
+     */
+    features_inheritance_removal_check_features(db,
+                                                "http://libosinfo.org/test/os/features/basic/1",
+                                                1);
+
+    /*
+     * http://libosinfo.org/test/os/features/removed/1 derives-from
+     * http://libosinfo.org/test/os/features/basic/1 ...
+     * And the feature is marked as removed
+     */
+    features_inheritance_removal_check_features(db,
+                                                "http://libosinfo.org/test/os/features/removed/1",
+                                                0);
+
+    /*
+     * 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",
+                                                0);
+
+    /*
+     * 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",
+                                                0);
+
+    /*
+     * 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",
+                                                1);
+
+    /*
+     * 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",
+                                                1);
+
+
+    /*
+     * 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",
+                                                1);
+
+    g_object_unref(db);
+}
+
+
 static void
 check_resources(OsinfoDb *db,
                 const gchar *os_id,
@@ -1103,6 +1196,8 @@ main(int argc, char *argv[])
     g_test_add_func("/os/features/duplication", test_features_duplication);
     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




More information about the Libosinfo mailing list