aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-10-08 10:04:15 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-10-08 10:04:16 +0100
commitdf51a005192ee40b469c9714d451bf49b6eb7fa7 (patch)
treefd945907bef44d6a19c28d8d174f69039a08b2b6 /tests
parente2e3436add538be0e558cdc42f3e6b76e9deb0f9 (diff)
parent1195fa2b08d98ab503155c5cee8831d1ef91aac5 (diff)
Merge remote-tracking branch 'remotes/elmarco/tags/option-pull-request' into staging
CLI help improvements PULLv2: - fix uninitialized "seentype" variable in qom-test # gpg: Signature made Fri 05 Oct 2018 13:28:21 BST # gpg: using RSA key DAE8E10975969CE5 # gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" # gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>" # Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5 * remotes/elmarco/tags/option-pull-request: vl: list user creatable properties when 'help' is argument hostmem: add some properties description vl: handle -object help tests/qom-proplist: check class properties iterator tests/qom-proplist: check properties are not listed multiple times tests/qom-proplist: check duplicate "bv" property registration failed qom/object: register 'type' property as class property qom/object: fix iterating properties over a class qemu-option: improve qemu_opts_print_help() output qemu-option: add help fallback to print the list of options cutils: add qemu_pstrcmp0() qdev-monitor: print help to stdout Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/check-qom-proplist.c58
1 files changed, 37 insertions, 21 deletions
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index 92898e1520..a8b2958e6e 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -125,10 +125,13 @@ static char *dummy_get_sv(Object *obj,
static void dummy_init(Object *obj)
{
+ Error *err = NULL;
+
object_property_add_bool(obj, "bv",
dummy_get_bv,
dummy_set_bv,
- NULL);
+ &err);
+ error_free_or_abort(&err);
}
@@ -517,32 +520,19 @@ static void test_dummy_getenum(void)
}
-static void test_dummy_iterator(void)
+static void test_dummy_prop_iterator(ObjectPropertyIterator *iter)
{
- Object *parent = object_get_objects_root();
- DummyObject *dobj = DUMMY_OBJECT(
- object_new_with_props(TYPE_DUMMY,
- parent,
- "dummy0",
- &error_abort,
- "bv", "yes",
- "sv", "Hiss hiss hiss",
- "av", "platypus",
- NULL));
-
+ bool seenbv = false, seensv = false, seenav = false, seentype = false;
ObjectProperty *prop;
- ObjectPropertyIterator iter;
- bool seenbv = false, seensv = false, seenav = false, seentype;
- object_property_iter_init(&iter, OBJECT(dobj));
- while ((prop = object_property_iter_next(&iter))) {
- if (g_str_equal(prop->name, "bv")) {
+ while ((prop = object_property_iter_next(iter))) {
+ if (!seenbv && g_str_equal(prop->name, "bv")) {
seenbv = true;
- } else if (g_str_equal(prop->name, "sv")) {
+ } else if (!seensv && g_str_equal(prop->name, "sv")) {
seensv = true;
- } else if (g_str_equal(prop->name, "av")) {
+ } else if (!seenav && g_str_equal(prop->name, "av")) {
seenav = true;
- } else if (g_str_equal(prop->name, "type")) {
+ } else if (!seentype && g_str_equal(prop->name, "type")) {
/* This prop comes from the base Object class */
seentype = true;
} else {
@@ -554,10 +544,35 @@ static void test_dummy_iterator(void)
g_assert(seenav);
g_assert(seensv);
g_assert(seentype);
+}
+
+static void test_dummy_iterator(void)
+{
+ Object *parent = object_get_objects_root();
+ DummyObject *dobj = DUMMY_OBJECT(
+ object_new_with_props(TYPE_DUMMY,
+ parent,
+ "dummy0",
+ &error_abort,
+ "bv", "yes",
+ "sv", "Hiss hiss hiss",
+ "av", "platypus",
+ NULL));
+ ObjectPropertyIterator iter;
+ object_property_iter_init(&iter, OBJECT(dobj));
+ test_dummy_prop_iterator(&iter);
object_unparent(OBJECT(dobj));
}
+static void test_dummy_class_iterator(void)
+{
+ ObjectPropertyIterator iter;
+ ObjectClass *klass = object_class_by_name(TYPE_DUMMY);
+
+ object_class_property_iter_init(&iter, klass);
+ test_dummy_prop_iterator(&iter);
+}
static void test_dummy_delchild(void)
{
@@ -629,6 +644,7 @@ int main(int argc, char **argv)
g_test_add_func("/qom/proplist/badenum", test_dummy_badenum);
g_test_add_func("/qom/proplist/getenum", test_dummy_getenum);
g_test_add_func("/qom/proplist/iterator", test_dummy_iterator);
+ g_test_add_func("/qom/proplist/class_iterator", test_dummy_class_iterator);
g_test_add_func("/qom/proplist/delchild", test_dummy_delchild);
g_test_add_func("/qom/resolve/partial", test_qom_partial_path);