Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 269 lines (221 sloc) 7.473 kB
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
1 #include <config.h>
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <string.h>
7
8 #include <sys/types.h>
9 #include <fcntl.h>
10
11 #ifdef WITH_QEMU
12
36d8e7d build: consistently indent preprocessor directives
Eric Blake authored
13 # include "internal.h"
14 # include "testutils.h"
1d16f05 Update QEMU test cases for new file locations & API renames
Daniel P. Berrange authored
15 # include "qemu/qemu_command.h"
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
16
36d8e7d build: consistently indent preprocessor directives
Eric Blake authored
17 # include "testutilsqemu.h"
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
18
19 static struct qemud_driver driver;
20
21 static int blankProblemElements(char *data)
22 {
23 if (virtTestClearLineRegex("<name>[[:alnum:]]+</name>", data) < 0 ||
24 virtTestClearLineRegex("<uuid>([[:alnum:]]|-)+</uuid>", data) < 0 ||
2654578 xml: output memory unit for clarity
Eric Blake authored
25 virtTestClearLineRegex("<memory.*>[[:digit:]]+</memory>", data) < 0 ||
26 virtTestClearLineRegex("<currentMemory.*>[[:digit:]]+</currentMemory>",
27 data) < 0 ||
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
28 virtTestClearLineRegex("<readonly/>", data) < 0 ||
29 virtTestClearLineRegex("<sharable/>", data) < 0)
30 return -1;
31 return 0;
32 }
33
34 static int testCompareXMLToArgvFiles(const char *xml,
9e3525d tests: silence qemuargv2xmltest noise
Eric Blake authored
35 const char *cmdfile,
36 bool expect_warning) {
9ba4eb3 @photron tests: Lower stack usage below 4096 bytes
photron authored
37 char *expectxml = NULL;
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
38 char *actualxml = NULL;
9ba4eb3 @photron tests: Lower stack usage below 4096 bytes
photron authored
39 char *cmd = NULL;
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
40 int ret = -1;
41 virDomainDefPtr vmdef = NULL;
9e3525d tests: silence qemuargv2xmltest noise
Eric Blake authored
42 char *log;
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
43
9ba4eb3 @photron tests: Lower stack usage below 4096 bytes
photron authored
44 if (virtTestLoadFile(cmdfile, &cmd) < 0)
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
45 goto fail;
9ba4eb3 @photron tests: Lower stack usage below 4096 bytes
photron authored
46 if (virtTestLoadFile(xml, &expectxml) < 0)
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
47 goto fail;
48
ebbae35 @berrange Change extract pidfile & monitor config from QEMU command line
berrange authored
49 if (!(vmdef = qemuParseCommandLineString(driver.caps, cmd,
50 NULL, NULL, NULL)))
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
51 goto fail;
52
9e3525d tests: silence qemuargv2xmltest noise
Eric Blake authored
53 if ((log = virtTestLogContentAndReset()) == NULL)
54 goto fail;
55 if ((*log != '\0') != expect_warning) {
8fe454c build: expand rule to cover testsuite
Eric Blake authored
56 VIR_FREE(log);
9e3525d tests: silence qemuargv2xmltest noise
Eric Blake authored
57 goto fail;
58 }
8fe454c build: expand rule to cover testsuite
Eric Blake authored
59 VIR_FREE(log);
9e3525d tests: silence qemuargv2xmltest noise
Eric Blake authored
60
65842bf @berrange Remove virConnectPtr from all domain XML parsing/formatting APIs
berrange authored
61 if (!(actualxml = virDomainDefFormat(vmdef, 0)))
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
62 goto fail;
63
64 if (blankProblemElements(expectxml) < 0 ||
65 blankProblemElements(actualxml) < 0)
66 goto fail;
67
68 if (STRNEQ(expectxml, actualxml)) {
69 virtTestDifference(stderr, expectxml, actualxml);
70 goto fail;
71 }
72
73 ret = 0;
74
75 fail:
8fe454c build: expand rule to cover testsuite
Eric Blake authored
76 VIR_FREE(expectxml);
77 VIR_FREE(actualxml);
78 VIR_FREE(cmd);
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
79 virDomainDefFree(vmdef);
80 return ret;
81 }
82
83
84 struct testInfo {
85 const char *name;
910b019 @berrange Convert qemu command line flags to 64-bit int
berrange authored
86 unsigned long long extraFlags;
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
87 const char *migrateFrom;
88 };
89
9ba4eb3 @photron tests: Lower stack usage below 4096 bytes
photron authored
90 static int
91 testCompareXMLToArgvHelper(const void *data)
92 {
93 int result = -1;
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
94 const struct testInfo *info = data;
9ba4eb3 @photron tests: Lower stack usage below 4096 bytes
photron authored
95 char *xml = NULL;
96 char *args = NULL;
97
98 if (virAsprintf(&xml, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
99 abs_srcdir, info->name) < 0 ||
100 virAsprintf(&args, "%s/qemuxml2argvdata/qemuxml2argv-%s.args",
101 abs_srcdir, info->name) < 0)
102 goto cleanup;
103
104 result = testCompareXMLToArgvFiles(xml, args, !!info->extraFlags);
105
106 cleanup:
8fe454c build: expand rule to cover testsuite
Eric Blake authored
107 VIR_FREE(xml);
108 VIR_FREE(args);
9ba4eb3 @photron tests: Lower stack usage below 4096 bytes
photron authored
109 return result;
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
110 }
111
112
113
114 static int
20986e5 tests: simplify common setup
Eric Blake authored
115 mymain(void)
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
116 {
117 int ret = 0;
118
119 if ((driver.caps = testQemuCapsInit()) == NULL)
120 return EXIT_FAILURE;
121 if((driver.stateDir = strdup("/nowhere")) == NULL)
122 return EXIT_FAILURE;
123
36d8e7d build: consistently indent preprocessor directives
Eric Blake authored
124 # define DO_TEST_FULL(name, extraFlags, migrateFrom) \
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
125 do { \
126 const struct testInfo info = { name, extraFlags, migrateFrom }; \
127 if (virtTestRun("QEMU ARGV-2-XML " name, \
128 1, testCompareXMLToArgvHelper, &info) < 0) \
129 ret = -1; \
130 } while (0)
131
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
132 # define DO_TEST(name) \
133 DO_TEST_FULL(name, 0, NULL)
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
134
135 setenv("PATH", "/bin", 1);
136 setenv("USER", "test", 1);
137 setenv("LOGNAME", "test", 1);
138 setenv("HOME", "/home/test", 1);
139 unsetenv("TMPDIR");
140 unsetenv("LD_PRELOAD");
141 unsetenv("LD_LIBRARY_PATH");
142
143 /* Can't roundtrip vcpu cpuset attribute */
21642e8 qemu: Rename QEMUD_CMD_FLAG_* to QEMU_CAPS_*
Jiri Denemark authored
144 /*DO_TEST("minimal", QEMU_CAPS_NAME);*/
3b72650 @nertpinx tests: Add tests for dump-core option
nertpinx authored
145 DO_TEST("machine-core-on");
146 DO_TEST("machine-core-off");
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
147 DO_TEST("boot-cdrom");
148 DO_TEST("boot-network");
149 DO_TEST("boot-floppy");
b66d1be @bonzini qemu: parse and create -cpu ...,-kvmclock
bonzini authored
150 DO_TEST("kvmclock");
151 /* This needs <emulator>./qemu.sh</emulator> which doesn't work here. */
152 /*DO_TEST("cpu-kvmclock");*/
153
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
154 /* Can't roundtrip xenner arch */
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
155 /*DO_TEST("bootloader");*/
ec62a60 @nertpinx QEMU Tests for reboot-timeout
nertpinx authored
156
157 DO_TEST("reboot-timeout-enabled");
158 DO_TEST("reboot-timeout-disabled");
159
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
160 DO_TEST("clock-utc");
161 DO_TEST("clock-localtime");
162 DO_TEST("disk-cdrom");
163 DO_TEST("disk-cdrom-empty");
164 DO_TEST("disk-floppy");
165 DO_TEST("disk-many");
166 DO_TEST("disk-virtio");
167 DO_TEST("disk-xenvbd");
168 DO_TEST("disk-drive-boot-disk");
169 DO_TEST("disk-drive-boot-cdrom");
170 DO_TEST("disk-drive-fmt-qcow");
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
171 /* Can't roundtrip shareable+cache mode option */
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
172 /*DO_TEST("disk-drive-shared");*/
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
173 /* Can't roundtrip v1 writethrough option */
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
174 /*DO_TEST("disk-drive-cache-v1-wt");*/
175 DO_TEST("disk-drive-cache-v1-wb");
176 DO_TEST("disk-drive-cache-v1-none");
177 DO_TEST("disk-drive-error-policy-stop");
178 DO_TEST("disk-drive-error-policy-enospace");
4bb4109 qemu: add separate rerror_policy for disk errors
Laine Stump authored
179 DO_TEST("disk-drive-error-policy-wreport-rignore");
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
180 DO_TEST("disk-drive-cache-v2-wt");
181 DO_TEST("disk-drive-cache-v2-wb");
182 DO_TEST("disk-drive-cache-v2-none");
6ee52c1 @osier Add directsync cache mode support for disk driver
osier authored
183 DO_TEST("disk-drive-cache-directsync");
f887334 @saaros Add unsafe cache mode support for disk driver
saaros authored
184 DO_TEST("disk-drive-cache-unsafe");
715bf45 @jdurgin tests: Add tests for network disks
jdurgin authored
185 DO_TEST("disk-drive-network-nbd");
186 DO_TEST("disk-drive-network-rbd");
5745dc1 @liewegas qemu/rbd: improve rbd device specification
liewegas authored
187 /* older format using CEPH_ARGS env var */
188 DO_TEST("disk-drive-network-rbd-ceph-env");
715bf45 @jdurgin tests: Add tests for network disks
jdurgin authored
189 DO_TEST("disk-drive-network-sheepdog");
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
190 DO_TEST("disk-usb");
191 DO_TEST("graphics-vnc");
1d9c0a0 @crobinso qemu: Allow serving VNC over a unix domain socket
crobinso authored
192 DO_TEST("graphics-vnc-socket");
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
193
194 driver.vncSASL = 1;
195 driver.vncSASLdir = strdup("/root/.sasl2");
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
196 DO_TEST("graphics-vnc-sasl");
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
197 driver.vncTLS = 1;
198 driver.vncTLSx509verify = 1;
199 driver.vncTLSx509certdir = strdup("/etc/pki/tls/qemu");
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
200 DO_TEST("graphics-vnc-tls");
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
201 driver.vncSASL = driver.vncTLSx509verify = driver.vncTLS = 0;
8fe454c build: expand rule to cover testsuite
Eric Blake authored
202 VIR_FREE(driver.vncSASLdir);
203 VIR_FREE(driver.vncTLSx509certdir);
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
204 driver.vncSASLdir = driver.vncTLSx509certdir = NULL;
205
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
206 DO_TEST("graphics-sdl");
207 DO_TEST("graphics-sdl-fullscreen");
208 DO_TEST("nographics-vga");
209 DO_TEST("input-usbmouse");
210 DO_TEST("input-usbtablet");
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
211 /* Can't rountrip xenner arch */
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
212 /*DO_TEST("input-xen");*/
213 DO_TEST("misc-acpi");
65c4ae9 @nertpinx tests: Add tests for qemu S3/S4 state configuration
nertpinx authored
214 DO_TEST("misc-disable-s3");
215 DO_TEST("misc-disable-suspends");
216 DO_TEST("misc-enable-s4");
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
217 DO_TEST("misc-no-reboot");
218 DO_TEST("misc-uuid");
219 DO_TEST("net-user");
220 DO_TEST("net-virtio");
221 DO_TEST("net-eth");
222 DO_TEST("net-eth-ifname");
223
224 DO_TEST("serial-vc");
225 DO_TEST("serial-pty");
226 DO_TEST("serial-dev");
227 DO_TEST("serial-file");
228 DO_TEST("serial-unix");
229 DO_TEST("serial-tcp");
230 DO_TEST("serial-udp");
231 DO_TEST("serial-tcp-telnet");
232 DO_TEST("serial-many");
233 DO_TEST("parallel-tcp");
234 DO_TEST("console-compat");
235 DO_TEST("sound");
236 DO_TEST("watchdog");
237
238 DO_TEST("hostdev-usb-address");
239
240 DO_TEST("hostdev-pci-address");
241
d67c189 vcpu: improve vcpu support in qemu command line
Eric Blake authored
242 DO_TEST("smp");
243
10c5928 tests: clean up qemuargv2xmltest
Eric Blake authored
244 DO_TEST_FULL("restore-v1", 0, "stdio");
245 DO_TEST_FULL("restore-v2", 0, "stdio");
246 DO_TEST_FULL("restore-v2", 0, "exec:cat");
247 DO_TEST_FULL("migrate", 0, "tcp:10.0.0.1:5000");
248
9e3525d tests: silence qemuargv2xmltest noise
Eric Blake authored
249 DO_TEST_FULL("qemu-ns-no-env", 1, NULL);
a71be01 Add tests for the new Qemu namespace XML.
Chris Lalancette authored
250
8fe454c build: expand rule to cover testsuite
Eric Blake authored
251 VIR_FREE(driver.stateDir);
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
252 virCapabilitiesFree(driver.caps);
253
9943276 @nertpinx Cleanup for a return statement in source files
nertpinx authored
254 return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
255 }
256
257 VIRT_TEST_MAIN(mymain)
258
259 #else
da8061e build: properly skip tests
Eric Blake authored
260 # include "testutils.h"
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
261
cffba7e @photron tests: Unify style of test skipping code
photron authored
262 int
263 main(void)
264 {
265 return EXIT_AM_SKIP;
266 }
107a7bd @berrange Test case for QEMU driver ARGV -> XML conversion
berrange authored
267
268 #endif /* WITH_QEMU */
Something went wrong with that request. Please try again.