From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Amit Shah" <amit@kernel.org>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
dgilbert@redhat.com, "Richard Henderson" <rth@twiddle.net>,
"Andreas Färber" <afaerber@suse.de>,
"Igor Mammedov" <imammedo@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PATCH v2 08/10] tests: add user-creatable test to test-qdev-global-props
Date: Tue, 30 Oct 2018 19:04:51 +0400 [thread overview]
Message-ID: <20181030150453.9344-9-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20181030150453.9344-1-marcandre.lureau@redhat.com>
Add a TYPE_USER_CREATABLE object global property check.
Rename the test, since it is no longer QDev-specific.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
...dev-global-props.c => test-global-props.c} | 128 ++++++++++++++++--
tests/Makefile.include | 4 +-
2 files changed, 117 insertions(+), 15 deletions(-)
rename tests/{test-qdev-global-props.c => test-global-props.c} (74%)
diff --git a/tests/test-qdev-global-props.c b/tests/test-global-props.c
similarity index 74%
rename from tests/test-qdev-global-props.c
rename to tests/test-global-props.c
index 08e7f5c8e5..df047bfa1c 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-global-props.c
@@ -27,7 +27,100 @@
#include "hw/qdev.h"
#include "qom/object.h"
#include "qapi/visitor.h"
+#include "qom/object_interfaces.h"
+#define TYPE_DUMMY "qemu-dummy"
+
+typedef struct DummyObject DummyObject;
+typedef struct DummyObjectClass DummyObjectClass;
+
+#define DUMMY_OBJECT(obj) \
+ OBJECT_CHECK(DummyObject, (obj), TYPE_DUMMY)
+
+struct DummyObject {
+ Object parent_obj;
+
+ char *sv;
+};
+
+struct DummyObjectClass {
+ ObjectClass parent_class;
+};
+
+static void dummy_set_sv(Object *obj,
+ const char *value,
+ Error **errp)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ g_free(dobj->sv);
+ dobj->sv = g_strdup(value);
+}
+
+static char *dummy_get_sv(Object *obj,
+ Error **errp)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ return g_strdup(dobj->sv);
+}
+
+
+
+static void dummy_class_init(ObjectClass *cls, void *data)
+{
+ object_class_property_add_str(cls, "sv",
+ dummy_get_sv,
+ dummy_set_sv,
+ NULL);
+}
+
+
+static void dummy_finalize(Object *obj)
+{
+ DummyObject *dobj = DUMMY_OBJECT(obj);
+
+ g_free(dobj->sv);
+}
+
+
+static const TypeInfo dummy_info = {
+ .name = TYPE_DUMMY,
+ .parent = TYPE_OBJECT,
+ .instance_size = sizeof(DummyObject),
+ .instance_finalize = dummy_finalize,
+ .class_size = sizeof(DummyObjectClass),
+ .class_init = dummy_class_init,
+ .interfaces = (InterfaceInfo[]) {
+ { TYPE_USER_CREATABLE },
+ { }
+ }
+};
+
+static void test_global_props_uc_subprocess(void)
+{
+ DummyObject *d;
+ static GlobalProperty gp = {
+ TYPE_DUMMY, "sv", "foobar",
+ };
+
+ d = DUMMY_OBJECT(object_new(TYPE_DUMMY));
+ g_assert_null(d->sv);
+ object_unref(OBJECT(d));
+
+ object_property_register_global(&gp);
+ d = DUMMY_OBJECT(object_new(TYPE_DUMMY));
+ g_assert_cmpstr(d->sv, ==, "foobar");
+ object_unref(OBJECT(d));
+}
+
+static void test_global_props_uc(void)
+{
+ g_test_trap_subprocess("/global-props/usercreatable/subprocess", 0, 0);
+ g_test_trap_assert_passed();
+ g_test_trap_assert_stderr("");
+ g_test_trap_assert_stdout("");
+}
#define TYPE_STATIC_PROPS "static_prop_type"
#define STATIC_TYPE(obj) \
@@ -83,7 +176,8 @@ static void test_static_prop_subprocess(void)
static void test_static_prop(void)
{
- g_test_trap_subprocess("/qdev/properties/static/default/subprocess", 0, 0);
+ g_test_trap_subprocess("/global-props/qdev/static/default/subprocess",
+ 0, 0);
g_test_trap_assert_passed();
g_test_trap_assert_stderr("");
g_test_trap_assert_stdout("");
@@ -119,7 +213,7 @@ static void test_static_globalprop_subprocess(void)
static void test_static_globalprop(void)
{
- g_test_trap_subprocess("/qdev/properties/static/global/subprocess", 0, 0);
+ g_test_trap_subprocess("/global-props/qdev/static/global/subprocess", 0, 0);
g_test_trap_assert_passed();
g_test_trap_assert_stderr("");
g_test_trap_assert_stdout("");
@@ -245,7 +339,8 @@ static void test_dynamic_globalprop_subprocess(void)
static void test_dynamic_globalprop(void)
{
- g_test_trap_subprocess("/qdev/properties/dynamic/global/subprocess", 0, 0);
+ g_test_trap_subprocess("/global-props/qdev/dynamic/global/subprocess",
+ 0, 0);
g_test_trap_assert_passed();
g_test_trap_assert_stderr_unmatched("*prop1*");
g_test_trap_assert_stderr_unmatched("*prop2*");
@@ -290,7 +385,8 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
static void test_dynamic_globalprop_nouser(void)
{
- g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subprocess", 0, 0);
+ g_test_trap_subprocess("/global-props/qdev"
+ "/dynamic/global/nouser/subprocess", 0, 0);
g_test_trap_assert_passed();
g_test_trap_assert_stderr("");
g_test_trap_assert_stdout("");
@@ -323,6 +419,7 @@ int main(int argc, char **argv)
g_test_init(&argc, &argv, NULL);
module_call_init(MODULE_INIT_QOM);
+ type_register_static(&dummy_info);
type_register_static(&static_prop_type);
type_register_static(&subclass_type);
type_register_static(&dynamic_prop_type);
@@ -330,27 +427,32 @@ int main(int argc, char **argv)
type_register_static(&nohotplug_type);
type_register_static(&nondevice_type);
- g_test_add_func("/qdev/properties/static/default/subprocess",
+ g_test_add_func("/global-props/usercreatable/subprocess",
+ test_global_props_uc_subprocess);
+ g_test_add_func("/global-props/usercreatable",
+ test_global_props_uc);
+
+ g_test_add_func("/global-props/qdev/static/default/subprocess",
test_static_prop_subprocess);
- g_test_add_func("/qdev/properties/static/default",
+ g_test_add_func("/global-props/qdev/static/default",
test_static_prop);
- g_test_add_func("/qdev/properties/static/global/subprocess",
+ g_test_add_func("/global-props/qdev/static/global/subprocess",
test_static_globalprop_subprocess);
- g_test_add_func("/qdev/properties/static/global",
+ g_test_add_func("/global-props/qdev/static/global",
test_static_globalprop);
- g_test_add_func("/qdev/properties/dynamic/global/subprocess",
+ g_test_add_func("/global-props/qdev/dynamic/global/subprocess",
test_dynamic_globalprop_subprocess);
- g_test_add_func("/qdev/properties/dynamic/global",
+ g_test_add_func("/global-props/qdev/dynamic/global",
test_dynamic_globalprop);
- g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess",
+ g_test_add_func("/global-props/qdev/dynamic/global/nouser/subprocess",
test_dynamic_globalprop_nouser_subprocess);
- g_test_add_func("/qdev/properties/dynamic/global/nouser",
+ g_test_add_func("/global-props/qdev/dynamic/global/nouser",
test_dynamic_globalprop_nouser);
- g_test_add_func("/qdev/properties/global/subclass",
+ g_test_add_func("/global-props/qdev/global/subclass",
test_subclass_global_props);
g_test_run();
diff --git a/tests/Makefile.include b/tests/Makefile.include
index f77a495109..446de4afda 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -88,7 +88,7 @@ check-unit-y += tests/test-qht$(EXESUF)
check-unit-y += tests/test-qht-par$(EXESUF)
check-unit-y += tests/test-bitops$(EXESUF)
check-unit-y += tests/test-bitcnt$(EXESUF)
-check-unit-y += tests/test-qdev-global-props$(EXESUF)
+check-unit-y += tests/test-global-props$(EXESUF)
check-unit-y += tests/check-qom-interface$(EXESUF)
check-unit-y += tests/check-qom-proplist$(EXESUF)
check-unit-y += tests/test-qemu-opts$(EXESUF)
@@ -557,7 +557,7 @@ tests/atomic64-bench$(EXESUF): tests/atomic64-bench.o $(test-util-obj-y)
tests/fp/%:
$(MAKE) -C $(dir $@) $(notdir $@)
-tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
+tests/test-global-props$(EXESUF): tests/test-global-props.o \
hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\
hw/core/bus.o \
hw/core/irq.o \
--
2.19.0.271.gfe8321ec05
next prev parent reply other threads:[~2018-10-30 15:08 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-30 15:04 [Qemu-devel] [PATCH v2 00/10] hostmem: use object "id" for memory region name with >= 3.1 Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 01/10] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
2018-11-01 11:03 ` Igor Mammedov
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 02/10] accel: register global_props like machine globals Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 03/10] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-10-31 20:22 ` Eduardo Habkost
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 04/10] qom/globals: move qdev globals to qom Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 05/10] qom/globals: generalize object_property_set_globals() Marc-André Lureau
2018-10-31 20:12 ` Eduardo Habkost
2018-11-01 10:18 ` Igor Mammedov
2018-11-01 15:27 ` Eduardo Habkost
2018-11-01 15:58 ` Igor Mammedov
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 06/10] qom/object: set globals when initializing object Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 07/10] qom/object: add set_globals flags Marc-André Lureau
2018-10-31 20:23 ` Eduardo Habkost
2018-10-30 15:04 ` Marc-André Lureau [this message]
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 09/10] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1 Marc-André Lureau
2018-10-31 20:14 ` Eduardo Habkost
2018-11-01 14:59 ` Igor Mammedov
2018-11-20 12:00 ` Marc-André Lureau
2018-10-30 15:04 ` [Qemu-devel] [PATCH v2 10/10] hostmem: use object id for memory region name with >= 3.1 Marc-André Lureau
2018-10-31 20:27 ` Eduardo Habkost
2018-11-01 15:16 ` Igor Mammedov
2018-11-01 15:31 ` Eduardo Habkost
2018-10-31 14:41 ` [Qemu-devel] [PATCH v2 00/10] hostmem: use object "id" " no-reply
2018-10-31 14:43 ` no-reply
2018-11-03 3:37 ` no-reply
2018-11-03 3:39 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181030150453.9344-9-marcandre.lureau@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=afaerber@suse.de \
--cc=amit@kernel.org \
--cc=atar4qemu@gmail.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).