[Libosinfo] [libosinfo PATCH v3 08/12] test-os: Add basic tests for Guest Features

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


Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 tests/test-os.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tests/test-os.c b/tests/test-os.c
index 45598bb..7bf45cf 100644
--- a/tests/test-os.c
+++ b/tests/test-os.c
@@ -61,6 +61,33 @@ test_devices(void)
 }
 
 
+static void
+test_features(void)
+{
+    OsinfoOs *os = osinfo_os_new("awesome");
+    OsinfoFeature *feature1 = osinfo_feature_new("awesome:0", "cpu-hotplug", "x86_64");
+    OsinfoFeature *feature2 = osinfo_feature_new("awesome:1", "hyperv-relaxed", "x86_64");
+    OsinfoFeature *feature3 = osinfo_feature_new("awesome:2", "cpu-hotplug", "all");
+    OsinfoFeature *feature4 = osinfo_feature_new("awesome:3", "hyperv-relaxed", "i686");
+
+    osinfo_os_add_feature(os, feature1);
+    osinfo_os_add_feature(os, feature2);
+    osinfo_os_add_feature(os, feature3);
+    osinfo_os_add_feature(os, feature4);
+
+    OsinfoFeatureList *features = osinfo_os_get_feature_list(os, "x86_64");
+
+    g_assert_cmpint(osinfo_list_get_length(OSINFO_LIST(features)), ==, 2);
+    g_assert_true(osinfo_list_get_nth(OSINFO_LIST(features), 0) == OSINFO_ENTITY(feature1));
+    g_assert_true(osinfo_list_get_nth(OSINFO_LIST(features), 1) == OSINFO_ENTITY(feature2));
+
+    g_object_unref(features);
+    g_object_unref(feature1);
+    g_object_unref(feature2);
+    g_object_unref(os);
+}
+
+
 static void
 test_loader(void)
 {
@@ -947,6 +974,7 @@ main(int argc, char *argv[])
                     test_devices_inheritance_basic);
     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/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