This basic test only ensures that we can properly parse:
<domainCapabilities>
<os>
<enum name="firmeware">
<value>bios</value>
<value>efi</value>
</enum>
</os>
</domainCapabilities>
Signed-off-by: Fabiano FidĂȘncio <fidencio(a)redhat.com>
---
tests/test-gconfig.c | 33 ++++++++++++++++++++
tests/xml/gconfig-domain-capabilities-os.xml | 23 ++++++++++++++
2 files changed, 56 insertions(+)
create mode 100644 tests/xml/gconfig-domain-capabilities-os.xml
diff --git a/tests/test-gconfig.c b/tests/test-gconfig.c
index fda4fcb..6979578 100644
--- a/tests/test-gconfig.c
+++ b/tests/test-gconfig.c
@@ -791,6 +791,37 @@ static void test_domain_device_unknown(void)
g_free(xml);
}
+static void test_domain_capabilities_os(void)
+{
+ GVirConfigDomainCapabilities *domain_caps;
+ GVirConfigDomainCapabilitiesOs *os;
+ GList *firmwares, *l;
+ gsize i;
+ GVirConfigDomainOsFirmware expected_firmwares[] =
{GVIR_CONFIG_DOMAIN_OS_FIRMWARE_BIOS,
+
GVIR_CONFIG_DOMAIN_OS_FIRMWARE_EFI};
+ GError *error = NULL;
+ gchar *xml;
+
+ xml = load_xml("gconfig-domain-capabilities-os.xml");
+
+ domain_caps = gvir_config_domain_capabilities_new_from_xml(xml, &error);
+ g_assert_no_error(error);
+
+ os = gvir_config_domain_capabilities_get_os(domain_caps);
+ g_assert_nonnull(os);
+
+ firmwares = gvir_config_domain_capabilities_os_get_firmwares(os);
+ g_assert_nonnull(firmwares);
+
+ for (l = firmwares, i = 0; l != NULL; l = l->next, i++)
+ g_assert_cmpint(GPOINTER_TO_INT(l->data), ==, expected_firmwares[i]);
+
+
+ g_list_free(firmwares);
+ g_object_unref(os);
+ g_object_unref(domain_caps);
+ g_free(xml);
+}
int main(int argc, char **argv)
{
@@ -825,6 +856,8 @@ int main(int argc, char **argv)
test_domain_device_pci_hostdev);
g_test_add_func("/libvirt-gconfig/domain-device-unknown",
test_domain_device_unknown);
+ g_test_add_func("/libvirt-gconfig/domain-capabilities-os",
+ test_domain_capabilities_os);
return g_test_run();
}
diff --git a/tests/xml/gconfig-domain-capabilities-os.xml
b/tests/xml/gconfig-domain-capabilities-os.xml
new file mode 100644
index 0000000..7e813c6
--- /dev/null
+++ b/tests/xml/gconfig-domain-capabilities-os.xml
@@ -0,0 +1,23 @@
+<domainCapabilities>
+ <os supported='yes'>
+ <enum name='firmware'>
+ <value>bios</value>
+ <value>efi</value>
+ </enum>
+ <loader supported='yes'>
+ <value>/usr/share/edk2/ovmf/OVMF_CODE.fd</value>
+ <value>/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw</value>
+ <enum name='type'>
+ <value>rom</value>
+ <value>pflash</value>
+ </enum>
+ <enum name='readonly'>
+ <value>yes</value>
+ <value>no</value>
+ </enum>
+ <enum name='secure'>
+ <value>no</value>
+ </enum>
+ </loader>
+ </os>
+</domainCapabilities>
--
2.21.0