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
;
21 FLAG_IS_DIFFERENT
= 1 << 0,
22 FLAG_EXPECT_FAILURE
= 1 << 1,
23 } virBhyveXMLToXMLTestFlags
;
26 testCompareXMLToXMLHelper(const void *data
)
28 const struct testInfo
*info
= data
;
31 bool is_different
= info
->flags
& FLAG_IS_DIFFERENT
;
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)
40 ret
= testCompareDomXML2XMLFiles(driver
.caps
, driver
.xmlopt
, xml_in
,
41 is_different
? xml_out
: xml_in
,
43 TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS
);
45 if ((ret
!= 0) && (info
->flags
& FLAG_EXPECT_FAILURE
)) {
47 VIR_TEST_DEBUG("Got expected error: %s\n",
48 virGetLastErrorMessage());
63 if ((driver
.caps
= virBhyveCapsBuild()) == NULL
)
66 if ((driver
.xmlopt
= virBhyveDriverCreateXMLConf(&driver
)) == NULL
)
69 # define DO_TEST_FULL(name, flags) \
71 const struct testInfo info = {name, (flags)}; \
72 if (virTestRun("BHYVE XML-2-XML " name, \
73 testCompareXMLToXMLHelper, &info) < 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")
148 #endif /* WITH_BHYVE */