[Libosinfo] [libosinfo PATCH 27/31] test-os: Add basic tests for Guest Features

Fabiano Fidêncio fidencio at redhat.com
Fri Nov 23 10:15:16 UTC 2018


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

diff --git a/tests/test-os.c b/tests/test-os.c
index 0b586b2..b154e94 100644
--- a/tests/test-os.c
+++ b/tests/test-os.c
@@ -61,6 +61,31 @@ test_devices(void)
 }
 
 
+static void
+test_features(void)
+{
+    OsinfoOs *os = osinfo_os_new("awesome");
+    OsinfoFeature *feature1 = osinfo_feature_new("cpu-hotplug");
+    OsinfoFeature *feature2 = osinfo_feature_new("numa");
+
+    OsinfoFeatureLink *link1 = osinfo_os_add_feature(os, feature1);
+    osinfo_entity_add_param(OSINFO_ENTITY(link1), "foo", "bar");
+    OsinfoFeatureLink *link2 = osinfo_os_add_feature(os, feature2);
+    osinfo_entity_add_param(OSINFO_ENTITY(link2), "bar", "foo");
+
+    OsinfoFeatureList *features = osinfo_os_get_features(os, NULL);
+
+    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)
 {
@@ -894,6 +919,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.1




More information about the Libosinfo mailing list