[libvirt-designer][PATCH] test: Add new SimpleDisk test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This test is meant for adding CDROM, floppy and disk to a domain.
For now, each method has _file and _device variant, which are
tested for now.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---

Funny, when reviewing Chritophe's patches, I've found one forgotten branch too.

 libvirt-designer/test-designer-domain.c | 101 ++++++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)

diff --git a/libvirt-designer/test-designer-domain.c b/libvirt-designer/test-designer-domain.c
index bbd5a28..90f7e68 100644
--- a/libvirt-designer/test-designer-domain.c
+++ b/libvirt-designer/test-designer-domain.c
@@ -125,6 +125,41 @@ static const gchar *capslxcxml =
     "  </guest>"
     "</capabilities>";
 
+static const gchar *domain_machine_simple_iso_result =
+    "<domain>\n"
+    "  <devices>\n"
+    "    <disk type=\"file\">\n"
+    "      <source file=\"/foo/bar1\"/>\n"
+    "      <driver name=\"qemu\" type=\"raw\"/>\n"
+    "      <target bus=\"ide\" dev=\"hda\"/>\n"
+    "    </disk>\n"
+    "    <disk type=\"block\">\n"
+    "      <source dev=\"/foo/bar2\"/>\n"
+    "      <driver name=\"qemu\" type=\"raw\"/>\n"
+    "      <target bus=\"ide\" dev=\"hdb\"/>\n"
+    "    </disk>\n"
+    "    <disk type=\"file\">\n"
+    "      <source file=\"/foo/bar3\"/>\n"
+    "      <driver name=\"qemu\" type=\"qcow2\"/>\n"
+    "      <target bus=\"ide\" dev=\"hdc\"/>\n"
+    "    </disk>\n"
+    "    <disk type=\"block\">\n"
+    "      <source dev=\"/foo/bar4\"/>\n"
+    "      <driver name=\"qemu\" type=\"raw\"/>\n"
+    "      <target bus=\"ide\" dev=\"hdd\"/>\n"
+    "    </disk>\n"
+    "    <disk type=\"file\">\n"
+    "      <source file=\"/foo/bar5\"/>\n"
+    "      <driver name=\"qemu\" type=\"bochs\"/>\n"
+    "      <target bus=\"ide\" dev=\"hde\"/>\n"
+    "    </disk>\n"
+    "    <disk type=\"block\">\n"
+    "      <source dev=\"/foo/bar6\"/>\n"
+    "      <driver name=\"qemu\" type=\"raw\"/>\n"
+    "      <target bus=\"ide\" dev=\"hdf\"/>\n"
+    "    </disk>\n"
+    "  </devices>\n"
+    "</domain>";
 
 static void test_domain_machine_setup(GVirDesignerDomain **design, gconstpointer opaque)
 {
@@ -142,6 +177,49 @@ static void test_domain_machine_setup(GVirDesignerDomain **design, gconstpointer
 }
 
 
+static void test_domain_machine_simple_disk_setup(GVirDesignerDomain **design, gconstpointer opaque)
+{
+    GError *error = NULL;
+    GVirConfigDomainDisk *disk;
+    OsinfoOs *os = osinfo_os_new("http://myoperatingsystem/amazing/4.2";);
+    OsinfoDb *db = osinfo_db_new();
+    OsinfoPlatform *platform = osinfo_platform_new("http://myhypervisor.org/awesome/6.6.6";);
+    GVirConfigCapabilities *caps = gvir_config_capabilities_new_from_xml(capsqemuxml, NULL);
+
+    *design = gvir_designer_domain_new(db, os, platform, caps);
+    g_assert(*design);
+
+    disk = gvir_designer_domain_add_cdrom_file(*design, "/foo/bar1", "raw", &error);
+    g_assert(disk);
+    g_object_unref(disk);
+
+    disk = gvir_designer_domain_add_cdrom_device(*design, "/foo/bar2", &error);
+    g_assert(disk);
+    g_object_unref(disk);
+
+    disk = gvir_designer_domain_add_disk_file(*design, "/foo/bar3", "qcow2", &error);
+    g_assert(disk);
+    g_object_unref(disk);
+
+    disk = gvir_designer_domain_add_disk_device(*design, "/foo/bar4", &error);
+    g_assert(disk);
+    g_object_unref(disk);
+
+    disk = gvir_designer_domain_add_floppy_file(*design, "/foo/bar5", "bochs", &error);
+    g_assert(disk);
+    g_object_unref(disk);
+
+    disk = gvir_designer_domain_add_disk_device(*design, "/foo/bar6", &error);
+    g_assert(disk);
+    g_object_unref(disk);
+
+    g_object_unref(os);
+    g_object_unref(db);
+    g_object_unref(platform);
+    g_object_unref(caps);
+}
+
+
 static void test_domain_container_setup(GVirDesignerDomain **design, gconstpointer opaque)
 {
     OsinfoOs *os = osinfo_os_new("http://myoperatingsystem/amazing/4.2";);
@@ -243,6 +321,22 @@ static void test_domain_machine_alt_arch_run(GVirDesignerDomain **design, gconst
     g_object_unref(osconfig);
 }
 
+static void test_domain_machine_simple_disk_run(GVirDesignerDomain **design, gconstpointer opaque)
+{
+    GError *error = NULL;
+    gboolean ret;
+    GVirConfigDomain *config;
+    gchar *xml;
+
+    config = gvir_designer_domain_get_config(*design);
+    xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(config));
+    g_test_message("XML %s", xml);
+    g_assert_cmpstr(xml,
+                    ==,
+                    domain_machine_simple_iso_result);
+    g_free(xml);
+}
+
 static void test_domain_container_host_arch_run(GVirDesignerDomain **design, gconstpointer opaque)
 {
     GError *error = NULL;
@@ -362,5 +456,12 @@ int main(int argc, char **argv)
                test_domain_container_setup,
                test_domain_container_alt_arch_run,
                test_domain_teardown);
+    g_test_add("/TestDesignerDomain/SimpleDisk",
+               GVirDesignerDomain *,
+               &domain,
+               test_domain_machine_simple_disk_setup,
+               test_domain_machine_simple_disk_run,
+               test_domain_teardown);
+
     return g_test_run();
 }
-- 
2.0.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]