remote: add sysusers file to create 'libvirt' group
[libvirt.git] / tests / bhyvexml2xmltest.c
blob428f1b47bbb97d243f91dd80a07dea4b8f58081f
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 g_autofree char *xml_in = NULL;
30 g_autofree char *xml_out = NULL;
31 bool is_different = info->flags & FLAG_IS_DIFFERENT;
32 int ret = -1;
34 xml_in = g_strdup_printf("%s/bhyvexml2argvdata/bhyvexml2argv-%s.xml",
35 abs_srcdir, info->name);
36 xml_out = g_strdup_printf("%s/bhyvexml2xmloutdata/bhyvexml2xmlout-%s.xml",
37 abs_srcdir, info->name);
39 ret = testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, xml_in,
40 is_different ? xml_out : xml_in,
41 false, 0,
42 TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
44 if ((ret != 0) && (info->flags & FLAG_EXPECT_FAILURE)) {
45 ret = 0;
46 VIR_TEST_DEBUG("Got expected error: %s",
47 virGetLastErrorMessage());
48 virResetLastError();
51 return ret;
54 static int
55 mymain(void)
57 int ret = 0;
59 if ((driver.caps = virBhyveCapsBuild()) == NULL)
60 return EXIT_FAILURE;
62 if ((driver.xmlopt = virBhyveDriverCreateXMLConf(&driver)) == NULL)
63 return EXIT_FAILURE;
65 # define DO_TEST_FULL(name, flags) \
66 do { \
67 const struct testInfo info = {name, (flags)}; \
68 if (virTestRun("BHYVE XML-2-XML " name, \
69 testCompareXMLToXMLHelper, &info) < 0) \
70 ret = -1; \
71 } while (0)
73 # define DO_TEST_DIFFERENT(name) \
74 DO_TEST_FULL(name, FLAG_IS_DIFFERENT)
76 # define DO_TEST_FAILURE(name) \
77 DO_TEST_FULL(name, FLAG_EXPECT_FAILURE)
79 driver.bhyvecaps = BHYVE_CAP_AHCI32SLOT;
81 DO_TEST_DIFFERENT("acpiapic");
82 DO_TEST_DIFFERENT("base");
83 DO_TEST_DIFFERENT("wired");
84 DO_TEST_DIFFERENT("bhyveload-bootorder");
85 DO_TEST_DIFFERENT("bhyveload-bootorder1");
86 DO_TEST_DIFFERENT("bhyveload-bootorder2");
87 DO_TEST_DIFFERENT("bhyveload-bootorder3");
88 DO_TEST_DIFFERENT("bhyveload-bootorder4");
89 DO_TEST_DIFFERENT("bhyveload-explicitargs");
90 DO_TEST_DIFFERENT("console");
91 DO_TEST_DIFFERENT("console-master-slave-not-specified");
92 DO_TEST_DIFFERENT("custom-loader");
93 DO_TEST_DIFFERENT("disk-cdrom");
94 DO_TEST_DIFFERENT("disk-cdrom-grub");
95 DO_TEST_DIFFERENT("disk-virtio");
96 DO_TEST_DIFFERENT("grub-bootorder");
97 DO_TEST_DIFFERENT("grub-bootorder2");
98 DO_TEST_DIFFERENT("grub-defaults");
99 DO_TEST_DIFFERENT("localtime");
100 DO_TEST_DIFFERENT("macaddr");
101 DO_TEST_DIFFERENT("metadata");
102 DO_TEST_DIFFERENT("serial");
103 DO_TEST_DIFFERENT("serial-grub");
104 DO_TEST_DIFFERENT("serial-grub-nocons");
105 DO_TEST_DIFFERENT("vnc");
106 DO_TEST_DIFFERENT("vnc-vgaconf-on");
107 DO_TEST_DIFFERENT("vnc-vgaconf-off");
108 DO_TEST_DIFFERENT("vnc-vgaconf-io");
109 DO_TEST_DIFFERENT("vnc-autoport");
110 DO_TEST_DIFFERENT("vnc-resolution");
111 DO_TEST_DIFFERENT("vnc-password");
112 DO_TEST_DIFFERENT("commandline");
113 DO_TEST_DIFFERENT("msrs");
114 DO_TEST_DIFFERENT("sound");
115 DO_TEST_DIFFERENT("isa-controller");
116 DO_TEST_DIFFERENT("fs-9p");
118 /* Address allocation tests */
119 DO_TEST_DIFFERENT("addr-single-sata-disk");
120 DO_TEST_DIFFERENT("addr-multiple-sata-disks");
121 DO_TEST_DIFFERENT("addr-more-than-32-sata-disks");
122 DO_TEST_DIFFERENT("addr-single-virtio-disk");
123 DO_TEST_DIFFERENT("addr-multiple-virtio-disks");
124 DO_TEST_DIFFERENT("addr-isa-controller-on-slot-1");
125 DO_TEST_DIFFERENT("addr-isa-controller-on-slot-31");
127 /* The same without 32 devs per controller support */
128 driver.bhyvecaps ^= BHYVE_CAP_AHCI32SLOT;
129 DO_TEST_DIFFERENT("addr-no32devs-single-sata-disk");
130 DO_TEST_DIFFERENT("addr-no32devs-multiple-sata-disks");
131 DO_TEST_FAILURE("addr-no32devs-more-than-32-sata-disks");
133 /* USB xhci tablet */
134 DO_TEST_DIFFERENT("input-xhci-tablet");
136 virObjectUnref(driver.caps);
137 virObjectUnref(driver.xmlopt);
139 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
142 VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("bhyvexml2argv"))
144 #else
147 main(void)
149 return EXIT_AM_SKIP;
152 #endif /* WITH_BHYVE */