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.
14 #include "qemu/osdep.h"
15 #include "qapi/qmp/types.h"
17 static const char *blacklist_x86[] = {
18 "xenfv", "xenpv", NULL
25 { "i386", blacklist_x86 },
26 { "x86_64", blacklist_x86 },
29 static bool is_blacklisted(const char *arch, const char *mach)
34 for (i = 0; i < ARRAY_SIZE(blacklists); i++) {
35 if (!strcmp(blacklists[i].arch, arch)) {
36 for (p = blacklists[i].machine; *p; p++) {
37 if (!strcmp(*p, mach)) {
46 static void test_machine(gconstpointer data)
48 const char *machine = data;
52 args = g_strdup_printf("-machine %s", machine);
54 response = qmp("{ 'execute': 'quit' }");
55 g_assert(qdict_haskey(response, "return"));
60 static void add_machine_test_cases(void)
62 const char *arch = qtest_get_arch();
63 QDict *response, *minfo;
68 const char *mname, *path;
70 qtest_start("-machine none");
71 response = qmp("{ 'execute': 'query-machines' }");
73 list = qdict_get_qlist(response, "return");
76 for (p = qlist_first(list); p; p = qlist_next(p)) {
77 minfo = qobject_to_qdict(qlist_entry_obj(p));
79 qobj = qdict_get(minfo, "name");
81 qstr = qobject_to_qstring(qobj);
83 mname = qstring_get_str(qstr);
84 if (!is_blacklisted(arch, mname)) {
85 path = g_strdup_printf("/%s/qom/%s", arch, mname);
86 g_test_add_data_func(path, mname, test_machine);
92 int main(int argc, char **argv)
94 g_test_init(&argc, &argv, NULL);
96 add_machine_test_cases();