2 * Device introspection test cases
4 * Copyright (c) 2015 Red Hat Inc.
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
14 * Covers QMP device-list-properties and HMP device_add help. We
15 * currently don't check that their output makes sense, only that QEMU
16 * survives. Useful since we've had an astounding number of crash
20 #include "qemu/osdep.h"
21 #include "qemu-common.h"
22 #include "qapi/qmp/qstring.h"
25 const char common_args[] = "-nodefaults -machine none";
27 static QList *device_type_list(bool abstract)
32 resp = qmp("{'execute': 'qom-list-types',"
33 " 'arguments': {'implements': 'device', 'abstract': %i}}",
35 g_assert(qdict_haskey(resp, "return"));
36 ret = qdict_get_qlist(resp, "return");
42 static void test_one_device(const char *type)
45 char *help, *qom_tree;
47 resp = qmp("{'execute': 'device-list-properties',"
48 " 'arguments': {'typename': %s}}",
52 help = hmp("device_add \"%s,help\"", type);
56 * Some devices leave dangling pointers in QOM behind.
57 * "info qom-tree" has a good chance at crashing then
59 qom_tree = hmp("info qom-tree");
63 static void test_device_intro_list(void)
68 qtest_start(common_args);
70 types = device_type_list(true);
73 help = hmp("device_add help");
79 static void test_device_intro_none(void)
81 qtest_start(common_args);
82 test_one_device("nonexistent");
86 static void test_device_intro_abstract(void)
88 qtest_start(common_args);
89 test_one_device("device");
93 static void test_device_intro_concrete(void)
99 qtest_start(common_args);
100 types = device_type_list(false);
102 QLIST_FOREACH_ENTRY(types, entry) {
103 type = qdict_get_try_str(qobject_to_qdict(qlist_entry_obj(entry)),
106 test_one_device(type);
113 int main(int argc, char **argv)
115 g_test_init(&argc, &argv, NULL);
117 qtest_add_func("device/introspect/list", test_device_intro_list);
118 qtest_add_func("device/introspect/none", test_device_intro_none);
119 qtest_add_func("device/introspect/abstract", test_device_intro_abstract);
120 qtest_add_func("device/introspect/concrete", test_device_intro_concrete);