qmp: access the local QemuOptsLists for drive option
[qemu.git] / tests / qom-test.c
blob6ed23c5e542c27399f74ead0df795aff13a70e51
1 /*
2 * QTest testcase for QOM
4 * Copyright (c) 2013 SUSE LINUX Products GmbH
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9 #include "libqtest.h"
11 #include <glib.h>
12 #include <string.h>
13 #include "qemu/osdep.h"
15 static void test_nop(gconstpointer data)
17 QTestState *s;
18 const char *machine = data;
19 char *args;
21 args = g_strdup_printf("-display none -machine %s", machine);
22 s = qtest_start(args);
23 if (s) {
24 qtest_quit(s);
26 g_free(args);
29 static const char *x86_machines[] = {
30 "pc",
31 "isapc",
32 "q35",
35 static const char *alpha_machines[] = {
36 "clipper",
39 static const char *arm_machines[] = {
40 "integratorcp",
41 "versatilepb",
42 "versatileab",
43 "lm3s811evb",
44 "lm3s6965evb",
45 "collie",
46 "akita",
47 "spitz",
48 "borzoi",
49 "terrier",
50 "tosa",
51 "cheetah",
52 "sx1-v1",
53 "sx1",
54 "realview-eb",
55 "realview-eb-mpcore",
56 "realview-pb-a8",
57 "realview-pbx-a9",
58 "musicpal",
59 "mainstone",
60 "connex",
61 "verdex",
62 "z2",
63 "n800",
64 "n810",
65 "kzm",
66 "vexpress-a9",
67 "vexpress-a15",
68 "smdkc210",
69 "nuri",
70 "xilinx-zynq-a9",
71 "highbank",
72 "midway",
75 static const char *cris_machines[] = {
76 "axis-dev88",
79 static const char *lm32_machines[] = {
80 "lm32-evr",
81 "lm32-uclinux",
82 "milkymist",
85 static const char *m68k_machines[] = {
86 "mcf5208evb",
87 "an5206",
88 "dummy",
91 static const char *microblaze_machines[] = {
92 "petalogix-ml605",
93 "petalogix-s3adsp1800",
96 static const char *mips_machines[] = {
97 "malta",
98 "magnum",
99 "mips",
100 "mipssim",
101 "pica61",
104 static const char *moxie_machines[] = {
105 "moxiesim",
108 static const char *openrisc_machines[] = {
109 "or32-sim",
112 static const char *ppc_machines[] = {
113 "g3beige",
114 "mac99",
115 "prep",
116 "mpc8544ds",
117 "ppce500",
120 static const char *ppc64_machines[] = {
121 "pseries",
124 static const char *ppc405_machines[] = {
125 "ref405ep",
126 "taihu",
129 static const char *ppc440_machines[] = {
130 "bamboo",
131 "virtex-ml507",
134 static const char *s390_machines[] = {
135 "s390-virtio",
136 "s390-ccw-virtio",
139 static const char *superh_machines[] = {
140 "r2d",
141 "shix",
144 static const char *sparc_machines[] = {
145 "SS-4",
146 "SS-5",
147 "SS-10",
148 "SS-20",
149 "SS-600MP",
150 "LX",
151 "SPARCClassic",
152 "SPARCbook",
153 "leon3_generic",
156 static const char *sparc64_machines[] = {
157 "sun4u",
158 "sun4v",
159 "Niagara",
162 static const char *unicore32_machines[] = {
163 "puv3",
166 static const char *xtensa_machines[] = {
167 "sim",
168 "lx60",
169 "lx200",
172 static void add_test_cases(const char *arch, const char *machine)
174 char *path;
175 path = g_strdup_printf("/%s/qom/%s", arch, machine);
176 g_test_add_data_func(path, machine, test_nop);
179 #define ADD_MACHINE_TESTS(arch, array) do { \
180 int i; \
181 for (i = 0; i < ARRAY_SIZE(array); i++) { \
182 add_test_cases((arch), (array)[i]); \
184 } while (false)
186 int main(int argc, char **argv)
188 const char *arch = qtest_get_arch();
190 g_test_init(&argc, &argv, NULL);
192 add_test_cases(arch, "none");
194 if (strcmp(arch, "i386") == 0 ||
195 strcmp(arch, "x86_64") == 0) {
196 ADD_MACHINE_TESTS(arch, x86_machines);
197 } else if (strcmp(arch, "alpha") == 0) {
198 ADD_MACHINE_TESTS(arch, alpha_machines);
199 } else if (strcmp(arch, "arm") == 0) {
200 ADD_MACHINE_TESTS(arch, arm_machines);
201 } else if (strcmp(arch, "cris") == 0) {
202 ADD_MACHINE_TESTS(arch, cris_machines);
203 } else if (strcmp(arch, "lm32") == 0) {
204 ADD_MACHINE_TESTS(arch, lm32_machines);
205 } else if (strcmp(arch, "m68k") == 0) {
206 ADD_MACHINE_TESTS(arch, m68k_machines);
207 } else if (strcmp(arch, "microblaze") == 0 ||
208 strcmp(arch, "microblazeel") == 0) {
209 ADD_MACHINE_TESTS(arch, microblaze_machines);
210 } else if (strcmp(arch, "mips") == 0 ||
211 strcmp(arch, "mipsel") == 0 ||
212 strcmp(arch, "mips64") == 0) {
213 ADD_MACHINE_TESTS(arch, mips_machines);
214 } else if (strcmp(arch, "mips64el") == 0) {
215 ADD_MACHINE_TESTS(arch, mips_machines);
216 add_test_cases(arch, "fulong2e");
217 } else if (strcmp(arch, "moxie") == 0) {
218 ADD_MACHINE_TESTS(arch, moxie_machines);
219 } else if (strcmp(arch, "or32") == 0) {
220 ADD_MACHINE_TESTS(arch, openrisc_machines);
221 } else if (strcmp(arch, "ppcemb") == 0) {
222 #if 0
223 /* XXX Available in ppcemb but don't work */
224 ADD_MACHINE_TESTS(arch, ppc405_machines);
225 #endif
226 ADD_MACHINE_TESTS(arch, ppc440_machines);
227 } else if (strcmp(arch, "ppc") == 0) {
228 ADD_MACHINE_TESTS(arch, ppc405_machines);
229 ADD_MACHINE_TESTS(arch, ppc440_machines);
230 ADD_MACHINE_TESTS(arch, ppc_machines);
231 } else if (strcmp(arch, "ppc64") == 0) {
232 ADD_MACHINE_TESTS(arch, ppc405_machines);
233 ADD_MACHINE_TESTS(arch, ppc440_machines);
234 ADD_MACHINE_TESTS(arch, ppc_machines);
235 ADD_MACHINE_TESTS(arch, ppc64_machines);
236 } else if (strcmp(arch, "s390x") == 0) {
237 ADD_MACHINE_TESTS(arch, s390_machines);
238 } else if (strcmp(arch, "sh4") == 0 ||
239 strcmp(arch, "sh4eb") == 0) {
240 ADD_MACHINE_TESTS(arch, superh_machines);
241 } else if (strcmp(arch, "sparc") == 0) {
242 ADD_MACHINE_TESTS(arch, sparc_machines);
243 } else if (strcmp(arch, "sparc64") == 0) {
244 ADD_MACHINE_TESTS(arch, sparc64_machines);
245 } else if (strcmp(arch, "unicore32") == 0) {
246 ADD_MACHINE_TESTS(arch, unicore32_machines);
247 } else if (strcmp(arch, "xtensa") == 0 ||
248 strcmp(arch, "xtensaeb") == 0) {
249 ADD_MACHINE_TESTS(arch, xtensa_machines);
252 return g_test_run();