aboutsummaryrefslogtreecommitdiff
path: root/tests/qom-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/qom-test.c')
-rw-r--r--tests/qom-test.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/tests/qom-test.c b/tests/qom-test.c
index d48f890e84..ab0595dc75 100644
--- a/tests/qom-test.c
+++ b/tests/qom-test.c
@@ -107,46 +107,22 @@ static void test_machine(gconstpointer data)
g_free((void *)machine);
}
-static void add_machine_test_cases(void)
+static void add_machine_test_case(const char *mname)
{
const char *arch = qtest_get_arch();
- QDict *response, *minfo;
- QList *list;
- const QListEntry *p;
- QObject *qobj;
- QString *qstr;
- const char *mname;
- qtest_start("-machine none");
- response = qmp("{ 'execute': 'query-machines' }");
- g_assert(response);
- list = qdict_get_qlist(response, "return");
- g_assert(list);
-
- for (p = qlist_first(list); p; p = qlist_next(p)) {
- minfo = qobject_to_qdict(qlist_entry_obj(p));
- g_assert(minfo);
- qobj = qdict_get(minfo, "name");
- g_assert(qobj);
- qstr = qobject_to_qstring(qobj);
- g_assert(qstr);
- mname = qstring_get_str(qstr);
- if (!is_blacklisted(arch, mname)) {
- char *path = g_strdup_printf("qom/%s", mname);
- qtest_add_data_func(path, g_strdup(mname), test_machine);
- g_free(path);
- }
+ if (!is_blacklisted(arch, mname)) {
+ char *path = g_strdup_printf("qom/%s", mname);
+ qtest_add_data_func(path, g_strdup(mname), test_machine);
+ g_free(path);
}
-
- qtest_end();
- QDECREF(response);
}
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
- add_machine_test_cases();
+ qtest_cb_for_every_machine(add_machine_test_case);
return g_test_run();
}