backup: Wire up qemu full pull backup commands over QMP
[libvirt/ericb.git] / tests / bhyvexml2xmltest.c
blobe8a6867fcd57a3026f89b2b0cfa44076bff8bc57
1 #include <config.h>
3 #include "testutils.h"
5 #ifdef WITH_BHYVE
7 # include "bhyve/bhyve_capabilities.h"
8 # include "bhyve/bhyve_domain.h"
9 # include "bhyve/bhyve_utils.h"
11 # define VIR_FROM_THIS VIR_FROM_NONE
13 static bhyveConn driver;
15 struct testInfo {
16 const char *name;
17 unsigned int flags;
20 typedef enum {
21 FLAG_IS_DIFFERENT = 1 << 0,
22 FLAG_EXPECT_FAILURE = 1 << 1,
23 } virBhyveXMLToXMLTestFlags;
25 static int
26 testCompareXMLToXMLHelper(const void *data)
28 const struct testInfo *info = data;
29 char *xml_in = NULL;
30 char *xml_out = NULL;
31 bool is_different = info->flags & FLAG_IS_DIFFERENT;
32 int ret = -1;
34 if (virAsprintf(&xml_in, "%s/bhyvexml2argvdata/bhyvexml2argv-%s.xml",
35 abs_srcdir, info->name) < 0 ||
36 virAsprintf(&xml_out, "%s/bhyvexml2xmloutdata/bhyvexml2xmlout-%s.xml",
37 abs_srcdir, info->name) < 0)
38 goto cleanup;
40 ret = testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, xml_in,
41 is_different ? xml_out : xml_in,
42 false, 0,
43 TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
45 if ((ret != 0) && (info->flags & FLAG_EXPECT_FAILURE)) {
46 ret = 0;
47 VIR_TEST_DEBUG("Got expected error: %s\n",
48 virGetLastErrorMessage());
49 virResetLastError();
52 cleanup:
53 VIR_FREE(xml_in);
54 VIR_FREE(xml_out);
55 return ret;
58 static int
59 mymain(void)
61 int ret = 0;
63 if ((driver.caps = virBhyveCapsBuild()) == NULL)
64 return EXIT_FAILURE;
66 if ((driver.xmlopt = virBhyveDriverCreateXMLConf(&driver)) == NULL)
67 return EXIT_FAILURE;
69 # define DO_TEST_FULL(name, flags) \
70 do { \
71 const struct testInfo info = {name, (flags)}; \
72 if (virTestRun("BHYVE XML-2-XML " name, \
73 testCompareXMLToXMLHelper, &info) < 0) \
74 ret = -1; \
75 } while (0)
77 # define DO_TEST_DIFFERENT(name) \
78 DO_TEST_FULL(name, FLAG_IS_DIFFERENT)
80 # define DO_TEST_FAILURE(name) \
81 DO_TEST_FULL(name, FLAG_EXPECT_FAILURE)
83 driver.bhyvecaps = BHYVE_CAP_AHCI32SLOT;
85 DO_TEST_DIFFERENT("acpiapic");
86 DO_TEST_DIFFERENT("base");
87 DO_TEST_DIFFERENT("wired");
88 DO_TEST_DIFFERENT("bhyveload-bootorder");
89 DO_TEST_DIFFERENT("bhyveload-bootorder1");
90 DO_TEST_DIFFERENT("bhyveload-bootorder2");
91 DO_TEST_DIFFERENT("bhyveload-bootorder3");
92 DO_TEST_DIFFERENT("bhyveload-bootorder4");
93 DO_TEST_DIFFERENT("bhyveload-explicitargs");
94 DO_TEST_DIFFERENT("console");
95 DO_TEST_DIFFERENT("custom-loader");
96 DO_TEST_DIFFERENT("disk-cdrom");
97 DO_TEST_DIFFERENT("disk-cdrom-grub");
98 DO_TEST_DIFFERENT("disk-virtio");
99 DO_TEST_DIFFERENT("grub-bootorder");
100 DO_TEST_DIFFERENT("grub-bootorder2");
101 DO_TEST_DIFFERENT("grub-defaults");
102 DO_TEST_DIFFERENT("localtime");
103 DO_TEST_DIFFERENT("macaddr");
104 DO_TEST_DIFFERENT("metadata");
105 DO_TEST_DIFFERENT("serial");
106 DO_TEST_DIFFERENT("serial-grub");
107 DO_TEST_DIFFERENT("serial-grub-nocons");
108 DO_TEST_DIFFERENT("vnc");
109 DO_TEST_DIFFERENT("vnc-vgaconf-on");
110 DO_TEST_DIFFERENT("vnc-vgaconf-off");
111 DO_TEST_DIFFERENT("vnc-vgaconf-io");
112 DO_TEST_DIFFERENT("vnc-autoport");
113 DO_TEST_DIFFERENT("commandline");
114 DO_TEST_DIFFERENT("msrs");
116 /* Address allocation tests */
117 DO_TEST_DIFFERENT("addr-single-sata-disk");
118 DO_TEST_DIFFERENT("addr-multiple-sata-disks");
119 DO_TEST_DIFFERENT("addr-more-than-32-sata-disks");
120 DO_TEST_DIFFERENT("addr-single-virtio-disk");
121 DO_TEST_DIFFERENT("addr-multiple-virtio-disks");
123 /* The same without 32 devs per controller support */
124 driver.bhyvecaps ^= BHYVE_CAP_AHCI32SLOT;
125 DO_TEST_DIFFERENT("addr-no32devs-single-sata-disk");
126 DO_TEST_DIFFERENT("addr-no32devs-multiple-sata-disks");
127 DO_TEST_FAILURE("addr-no32devs-more-than-32-sata-disks");
129 /* USB xhci tablet */
130 DO_TEST_DIFFERENT("input-xhci-tablet");
132 virObjectUnref(driver.caps);
133 virObjectUnref(driver.xmlopt);
135 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
138 VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/bhyvexml2argvmock.so")
140 #else
143 main(void)
145 return EXIT_AM_SKIP;
148 #endif /* WITH_BHYVE */