diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2017-07-07 18:30:51 -0300 |
---|---|---|
committer | Eduardo Habkost <ehabkost@redhat.com> | 2017-07-17 15:41:29 -0300 |
commit | 3f0058bbc1f057dee0c6b819b1119f1f58a3a6e8 (patch) | |
tree | 5fc8e78899a203c2afe8aaeb3293ab75f9549079 | |
parent | 2a6f395b9a849942804fae626dad505d17f247da (diff) | |
download | qemu-3f0058bbc1f057dee0c6b819b1119f1f58a3a6e8.zip qemu-3f0058bbc1f057dee0c6b819b1119f1f58a3a6e8.tar.gz qemu-3f0058bbc1f057dee0c6b819b1119f1f58a3a6e8.tar.bz2 |
tests: Test case for object_resolve_path*()
Test for partial path lookup using object_resolve_path*().
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20170707213052.13087-2-ehabkost@redhat.com>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
-rw-r--r-- | tests/check-qom-proplist.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 8e432e9..f6e7823 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -568,6 +568,44 @@ static void test_dummy_delchild(void) object_unparent(OBJECT(dev)); } +static void test_qom_partial_path(void) +{ + Object *root = object_get_objects_root(); + Object *cont1 = container_get(root, "/cont1"); + Object *obj1 = object_new(TYPE_DUMMY); + Object *obj2a = object_new(TYPE_DUMMY); + Object *obj2b = object_new(TYPE_DUMMY); + bool ambiguous; + + /* Objects created: + * /cont1 + * /cont1/obj1 + * /cont1/obj2 (obj2a) + * /obj2 (obj2b) + */ + object_property_add_child(cont1, "obj1", obj1, &error_abort); + object_unref(obj1); + object_property_add_child(cont1, "obj2", obj2a, &error_abort); + object_unref(obj2a); + object_property_add_child(root, "obj2", obj2b, &error_abort); + object_unref(obj2b); + + ambiguous = false; + g_assert(!object_resolve_path_type("", TYPE_DUMMY, &ambiguous)); + g_assert(ambiguous); + + ambiguous = false; + g_assert(!object_resolve_path("obj2", &ambiguous)); + g_assert(ambiguous); + + ambiguous = false; + g_assert(object_resolve_path("obj1", &ambiguous) == obj1); + g_assert(!ambiguous); + + object_unparent(obj2b); + object_unparent(cont1); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -585,6 +623,7 @@ int main(int argc, char **argv) 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/delchild", test_dummy_delchild); + g_test_add_func("/qom/resolve/partial", test_qom_partial_path); return g_test_run(); } |