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

Fabiano Fidêncio fidencio at redhat.com
Fri Jan 18 12:30:47 UTC 2019


Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 .../test-os-features-supported.xml            | 21 ++++++++++++++++
 tests/test-os.c                               | 25 +++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 tests/dbdata/os/libosinfo.org/test-os-features-supported.xml

diff --git a/tests/dbdata/os/libosinfo.org/test-os-features-supported.xml b/tests/dbdata/os/libosinfo.org/test-os-features-supported.xml
new file mode 100644
index 0000000..b044f93
--- /dev/null
+++ b/tests/dbdata/os/libosinfo.org/test-os-features-supported.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/supported">
+    <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 supported="false">cpu-hotplug</feature>
+    </features>
+  </os>
+</libosinfo>
diff --git a/tests/test-os.c b/tests/test-os.c
index 0aa6715..49994f5 100644
--- a/tests/test-os.c
+++ b/tests/test-os.c
@@ -88,6 +88,30 @@ test_features(void)
 }
 
 
+static void
+test_features_supported(void)
+{
+    OsinfoLoader *loader = osinfo_loader_new();
+    OsinfoDb *db;
+    OsinfoOs *os;
+    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);
+
+    os = osinfo_db_get_os(db, "http://libosinfo.org/test/os/features/supported");
+    g_assert(OSINFO_IS_OS(os));
+
+    g_assert_true(osinfo_os_is_feature_supported(os, "cpu-hotplug", "x86_64"));
+    g_assert_false(osinfo_os_is_feature_supported(os, "cpu-hotplug", "i686"));
+    g_assert_true(osinfo_os_is_feature_supported(os, "hyperv-relaxed", "x86_64"));
+
+    g_object_unref(db);
+}
+
+
 static void
 test_loader(void)
 {
@@ -1127,6 +1151,7 @@ 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/supported", test_features_supported);
     g_test_add_func("/os/features/inheritance/basic",
                     test_features_inheritance_basic);
     g_test_add_func("/os/features/inheritance/removal",
-- 
2.19.2




More information about the Libosinfo mailing list