aboutsummaryrefslogtreecommitdiff
path: root/tests/check-qom-proplist.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-09-06 18:13:34 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2018-10-05 16:26:09 +0400
commit94ef3b309273c37717fad34acd8c8b58a21861a0 (patch)
treea60cf532e038a7e5dc788a07b0febe78c3caf60a /tests/check-qom-proplist.c
parent9633017998c965e106f9ff4585ec09294c924c8e (diff)
downloadqemu-94ef3b309273c37717fad34acd8c8b58a21861a0.zip
qemu-94ef3b309273c37717fad34acd8c8b58a21861a0.tar.gz
qemu-94ef3b309273c37717fad34acd8c8b58a21861a0.tar.bz2
tests/qom-proplist: check properties are not listed multiple times
And factor out a common function used by the follow class properties iterator test. Fix uninitialized "seentype" variable. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/check-qom-proplist.c')
-rw-r--r--tests/check-qom-proplist.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index 0f6d9c1..2c07719 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -520,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 {
@@ -557,7 +544,24 @@ 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));
}