aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-01-20 16:42:07 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-01-20 16:42:07 +0000
commit598cf1c805271564686f2d732b36f50c3c40dcdd (patch)
treef512a9398bba3023126b7303160a91c8d30b0adb /tests
parentd1c82f7cc34443841095f490345f86c9d8baca34 (diff)
parentabc62c89f3191774dbd600a2caec803cbf557160 (diff)
downloadqemu-598cf1c805271564686f2d732b36f50c3c40dcdd.zip
qemu-598cf1c805271564686f2d732b36f50c3c40dcdd.tar.gz
qemu-598cf1c805271564686f2d732b36f50c3c40dcdd.tar.bz2
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* QOM interface fix (Eduardo) * RTC fixes (Gaohuai, Igor) * Memory leak fixes (Li Qiang, me) * Ctrl-a b regression (Marc-André) * Stubs cleanups and fixes (Leif, me) * hxtool tweak (me) * HAX support (Vincent) * QemuThread, exec.c and SCSI fixes (Roman, Xinhua, me) * PC_COMPAT_2_8 fix (Marcelo) * stronger bitmap assertions (Peter) # gpg: Signature made Fri 20 Jan 2017 12:49:01 GMT # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (35 commits) pc.h: move x-mach-use-reliable-get-clock compat entry to PC_COMPAT_2_8 bitmap: assert that start and nr are non negative Revert "win32: don't run subprocess tests on Mingw32 platform" hax: add Darwin support Plumb the HAXM-based hardware acceleration support target/i386: Add Intel HAX files kvm: move cpu synchronization code KVM: PPC: eliminate unnecessary duplicate constants ramblock-notifier: new char: fix ctrl-a b not working exec: Add missing rcu_read_unlock x86: ioapic: fix fail migration when irqchip=split x86: ioapic: dump version for "info ioapic" x86: ioapic: add traces for ioapic hxtool: emit Texinfo headings as @subsection qemu-thread: fix qemu_thread_set_name() race in qemu_thread_create() serial: fix memory leak in serial exit scsi-block: fix direction of BYTCHK test for VERIFY commands pc: fix crash in rtc_set_memory() if initial cpu is marked as hotplugged acpi: filter based on CONFIG_ACPI_X86 rather than TARGET ... # Conflicts: # include/hw/i386/pc.h
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.include1
-rw-r--r--tests/device-introspect-test.c60
2 files changed, 58 insertions, 3 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 96f5970..22ea256 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -537,6 +537,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
hw/core/bus.o \
hw/core/irq.o \
hw/core/fw-path-provider.o \
+ hw/core/reset.o \
$(test-qapi-obj-y)
tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
migration/vmstate.o migration/qemu-file.o \
diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c
index 37debc1..c5637cc 100644
--- a/tests/device-introspect-test.c
+++ b/tests/device-introspect-test.c
@@ -20,18 +20,24 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/qmp/qstring.h"
+#include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qdict.h"
#include "libqtest.h"
const char common_args[] = "-nodefaults -machine none";
-static QList *device_type_list(bool abstract)
+static QList *qom_list_types(const char *implements, bool abstract)
{
QDict *resp;
QList *ret;
+ QDict *args = qdict_new();
+ qdict_put(args, "abstract", qbool_from_bool(abstract));
+ if (implements) {
+ qdict_put(args, "implements", qstring_from_str(implements));
+ }
resp = qmp("{'execute': 'qom-list-types',"
- " 'arguments': {'implements': 'device', 'abstract': %i}}",
- abstract);
+ " 'arguments': %p }", args);
g_assert(qdict_haskey(resp, "return"));
ret = qdict_get_qlist(resp, "return");
QINCREF(ret);
@@ -39,6 +45,11 @@ static QList *device_type_list(bool abstract)
return ret;
}
+static QList *device_type_list(bool abstract)
+{
+ return qom_list_types("device", abstract);
+}
+
static void test_one_device(const char *type)
{
QDict *resp;
@@ -110,6 +121,48 @@ static void test_device_intro_concrete(void)
qtest_end();
}
+static void test_abstract_interfaces(void)
+{
+ QList *all_types;
+ QList *obj_types;
+ QListEntry *ae;
+
+ qtest_start(common_args);
+ /* qom-list-types implements=interface would return any type
+ * that implements _any_ interface (not just interface types),
+ * so use a trick to find the interface type names:
+ * - list all object types
+ * - list all types, and look for items that are not
+ * on the first list
+ */
+ all_types = qom_list_types(NULL, false);
+ obj_types = qom_list_types("object", false);
+
+ QLIST_FOREACH_ENTRY(all_types, ae) {
+ QDict *at = qobject_to_qdict(qlist_entry_obj(ae));
+ const char *aname = qdict_get_str(at, "name");
+ QListEntry *oe;
+ const char *found = NULL;
+
+ QLIST_FOREACH_ENTRY(obj_types, oe) {
+ QDict *ot = qobject_to_qdict(qlist_entry_obj(oe));
+ const char *oname = qdict_get_str(ot, "name");
+ if (!strcmp(aname, oname)) {
+ found = oname;
+ break;
+ }
+ }
+
+ /* Using g_assert_cmpstr() will give more useful failure
+ * messages than g_assert(found) */
+ g_assert_cmpstr(aname, ==, found);
+ }
+
+ QDECREF(all_types);
+ QDECREF(obj_types);
+ qtest_end();
+}
+
int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
@@ -118,6 +171,7 @@ int main(int argc, char **argv)
qtest_add_func("device/introspect/none", test_device_intro_none);
qtest_add_func("device/introspect/abstract", test_device_intro_abstract);
qtest_add_func("device/introspect/concrete", test_device_intro_concrete);
+ qtest_add_func("device/introspect/abstract-interfaces", test_abstract_interfaces);
return g_test_run();
}