[Libosinfo] [libosinfo PATCH v3 09/12] test-os: Add test_features_inheritance_basic()
Fabiano Fidêncio
fidencio at redhat.com
Fri Jan 18 12:30:44 UTC 2019
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
.../test-os-features-basic-1.xml | 21 +++++++
.../test-os-features-basic-2-clone.xml | 10 +++
.../test-os-features-basic-2.xml | 10 +++
tests/test-os.c | 61 +++++++++++++++++++
4 files changed, 102 insertions(+)
create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-basic-1.xml
create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-basic-2-clone.xml
create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-basic-2.xml
diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-basic-1.xml b/tests/dbdata/os/libosinfo.org/test-os-features-basic-1.xml
new file mode 100644
index 0000000..183e0d5
--- /dev/null
+++ b/tests/dbdata/os/libosinfo.org/test-os-features-basic-1.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<libosinfo version="0.0.1">
+ <os id="http://libosinfo.org/test/os/features/basic/1">
+ <short-id>features-basic-1</short-id>
+ <name>Features Basic 1</name>
+ <vendor>libosinfo.org</vendor>
+ <family>test</family>
+
+ <features arch="all">
+ <feature>cpu-hotplug</feature>
+ </features>
+
+ <features arch="x86_64">
+ <feature state="on">hyperv-relaxed</feature>
+ </features>
+
+ <features arch="i686">
+ <feature state="off">hyperv-vapic</feature>
+ </features>
+ </os>
+</libosinfo>
diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-basic-2-clone.xml b/tests/dbdata/os/libosinfo.org/test-os-features-basic-2-clone.xml
new file mode 100644
index 0000000..cf65ea7
--- /dev/null
+++ b/tests/dbdata/os/libosinfo.org/test-os-features-basic-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/basic/2-clone">
+ <short-id>features-basic-2-clone</short-id>
+ <name>Features Basic 2 Clone</name>
+ <vendor>libosinfo.org</vendor>
+ <family>test</family>
+ <clones id="http://libosinfo.org/test/os/features/basic/2"/>
+ </os>
+</libosinfo>
diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-basic-2.xml b/tests/dbdata/os/libosinfo.org/test-os-features-basic-2.xml
new file mode 100644
index 0000000..d3af204
--- /dev/null
+++ b/tests/dbdata/os/libosinfo.org/test-os-features-basic-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/basic/2">
+ <short-id>features-basic-2</short-id>
+ <name>Features Basic 2</name>
+ <vendor>libosinfo.org</vendor>
+ <family>test</family>
+ <derives-from id="http://libosinfo.org/test/os/features/basic/1"/>
+ </os>
+</libosinfo>
diff --git a/tests/test-os.c b/tests/test-os.c
index 7bf45cf..851c99e 100644
--- a/tests/test-os.c
+++ b/tests/test-os.c
@@ -664,6 +664,65 @@ test_devices_inheritance_basic(void)
}
+static void
+features_inheritance_basic_check(OsinfoDb *db,
+ const gchar *os_id)
+{
+ OsinfoOs *os;
+ OsinfoFeatureList *feature_list;
+ OsinfoFeature *feature;
+ gsize i;
+
+ 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)), ==, 2);
+
+ for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(feature_list)); i++) {
+ feature = OSINFO_FEATURE(osinfo_list_get_nth(OSINFO_LIST(feature_list), i));
+ g_assert(OSINFO_IS_FEATURE(feature));
+ }
+
+ g_object_unref(feature_list);
+}
+
+
+static void
+test_features_inheritance_basic(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_basic_check(db, "http://libosinfo.org/test/os/features/basic/1");
+
+ /*
+ * http://libosinfo.org/test/os/features/basic/2 derives-from
+ * http://libosinfo.org/test/os/features/basic/1
+ */
+ features_inheritance_basic_check(db, "http://libosinfo.org/test/os/features/basic/2");
+
+ /*
+ * http://libosinfo.org/test/os/features/basic/2-clone clones
+ * http://libosinfo.org/test/os/features/basic/2
+ */
+ features_inheritance_basic_check(db, "http://libosinfo.org/test/os/features/basic/2-clone");
+
+ g_object_unref(db);
+}
+
+
static void
devices_inheritance_removal_check_devs(OsinfoDb *db,
const gchar *os_id,
@@ -975,6 +1034,8 @@ main(int argc, char *argv[])
g_test_add_func("/os/devices/inheritance/removal",
test_devices_inheritance_removal);
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/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