backup: Wire up qemu full pull backup commands over QMP
[libvirt/ericb.git] / tests / genericxml2xmltest.c
blob1840d6e6a8f995c2601cf175a53598598317c371
1 #include <config.h>
3 #include <unistd.h>
5 #include <sys/types.h>
6 #include <fcntl.h>
8 #include "testutils.h"
9 #include "internal.h"
10 #include "virstring.h"
12 #define VIR_FROM_THIS VIR_FROM_NONE
14 static virCapsPtr caps;
15 static virDomainXMLOptionPtr xmlopt;
17 struct testInfo {
18 const char *name;
19 int different;
20 bool inactive_only;
21 testCompareDomXML2XMLResult expectResult;
24 static int
25 testCompareXMLToXMLHelper(const void *data)
27 const struct testInfo *info = data;
28 char *xml_in = NULL;
29 char *xml_out = NULL;
30 int ret = -1;
32 if (virAsprintf(&xml_in, "%s/genericxml2xmlindata/%s.xml",
33 abs_srcdir, info->name) < 0 ||
34 virAsprintf(&xml_out, "%s/genericxml2xmloutdata/%s.xml",
35 abs_srcdir, info->name) < 0)
36 goto cleanup;
38 ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in,
39 info->different ? xml_out : xml_in,
40 !info->inactive_only, 0,
41 info->expectResult);
42 cleanup:
43 VIR_FREE(xml_in);
44 VIR_FREE(xml_out);
45 return ret;
49 static int
50 mymain(void)
52 int ret = 0;
54 if (!(caps = virTestGenericCapsInit()))
55 return EXIT_FAILURE;
57 if (!(xmlopt = virTestGenericDomainXMLConfInit()))
58 return EXIT_FAILURE;
60 #define DO_TEST_FULL(name, is_different, inactive, expectResult) \
61 do { \
62 const struct testInfo info = {name, is_different, inactive, \
63 expectResult}; \
64 if (virTestRun("GENERIC XML-2-XML " name, \
65 testCompareXMLToXMLHelper, &info) < 0) \
66 ret = -1; \
67 } while (0)
69 #define DO_TEST(name) \
70 DO_TEST_FULL(name, 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS)
72 #define DO_TEST_DIFFERENT(name) \
73 DO_TEST_FULL(name, 1, false, TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS)
75 DO_TEST_DIFFERENT("disk-virtio");
77 DO_TEST_DIFFERENT("graphics-vnc-minimal");
78 DO_TEST_DIFFERENT("graphics-vnc-manual-port");
79 DO_TEST_DIFFERENT("graphics-vnc-socket");
80 DO_TEST_DIFFERENT("graphics-vnc-socket-listen");
81 DO_TEST_DIFFERENT("graphics-listen-back-compat");
82 DO_TEST_FULL("graphics-listen-back-compat-mismatch", 0, false,
83 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
84 DO_TEST_DIFFERENT("graphics-vnc-listen-attr-only");
85 DO_TEST_DIFFERENT("graphics-vnc-listen-element-minimal");
86 DO_TEST_DIFFERENT("graphics-vnc-listen-element-with-address");
87 DO_TEST_DIFFERENT("graphics-vnc-socket-attr-listen-address");
88 DO_TEST_DIFFERENT("graphics-vnc-socket-attr-listen-socket");
89 DO_TEST_FULL("graphics-vnc-socket-attr-listen-socket-mismatch", 0, false,
90 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
91 DO_TEST("graphics-vnc-autoport-no");
93 DO_TEST_FULL("name-slash-fail", 0, false,
94 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
96 DO_TEST("perf");
98 DO_TEST("vcpus-individual");
99 DO_TEST("disk-network-http");
101 DO_TEST("cpu-cache-emulate");
102 DO_TEST("cpu-cache-passthrough");
103 DO_TEST("cpu-cache-disable");
105 DO_TEST_DIFFERENT("chardev-tcp");
106 DO_TEST_FULL("chardev-tcp-missing-host", 0, false,
107 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
108 DO_TEST_FULL("chardev-tcp-missing-service", 0, false,
109 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
110 DO_TEST_FULL("chardev-tcp-multiple-source", 0, false,
111 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
112 DO_TEST_DIFFERENT("chardev-udp");
113 DO_TEST_FULL("chardev-udp-missing-connect-service", 0, false,
114 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
115 DO_TEST_FULL("chardev-udp-multiple-source", 0, false,
116 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
117 DO_TEST_DIFFERENT("chardev-unix");
118 DO_TEST_FULL("chardev-unix-smartcard-missing-path", 0, false,
119 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
120 DO_TEST_FULL("chardev-unix-redirdev-missing-path", 0, false,
121 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
122 DO_TEST_FULL("chardev-unix-rng-missing-path", 0, false,
123 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
124 DO_TEST_DIFFERENT("chardev-reconnect");
125 DO_TEST_FULL("chardev-reconnect-missing-timeout", 0, false,
126 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
127 DO_TEST_FULL("chardev-reconnect-invalid-mode", 0, false,
128 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
130 DO_TEST("cachetune");
131 DO_TEST("cachetune-small");
132 DO_TEST("cachetune-cdp");
133 DO_TEST_DIFFERENT("cachetune-extra-tunes");
134 DO_TEST_FULL("cachetune-colliding-allocs", false, true,
135 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
136 DO_TEST_FULL("cachetune-colliding-tunes", false, true,
137 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
138 DO_TEST_FULL("cachetune-colliding-types", false, true,
139 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
140 DO_TEST_FULL("cachetune-colliding-monitor", false, true,
141 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
142 DO_TEST("memorytune");
143 DO_TEST_FULL("memorytune-colliding-allocs", false, true,
144 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
145 DO_TEST_FULL("memorytune-colliding-cachetune", false, true,
146 TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
148 DO_TEST("tseg");
150 DO_TEST("launch-security-sev");
152 DO_TEST_DIFFERENT("cputune");
154 virObjectUnref(caps);
155 virObjectUnref(xmlopt);
157 return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
160 VIR_TEST_MAIN(mymain)