From a3590dacce94519c1747d8bf423744c6bb7d9941 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 27 May 2015 16:07:56 +0100 Subject: qom: Don't pass string table to object_get_enum() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that properties can be explicitly registered as an enum type, there is no need to pass the string table to the object_get_enum() function. The object property registration already has a pointer to the string table. In changing this method signature, the hostmem backend object has to be converted to use the new enum property registration code, which simplifies it somewhat. Signed-off-by: Daniel P. Berrange Reviewed-by: Eric Blake Signed-off-by: Andreas Färber --- tests/check-qom-proplist.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests') diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index ae4cd4cde6..7400b1fce9 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -244,6 +244,48 @@ static void test_dummy_badenum(void) } +static void test_dummy_getenum(void) +{ + Error *err = NULL; + int val; + Object *parent = object_get_objects_root(); + DummyObject *dobj = DUMMY_OBJECT( + object_new_with_props(TYPE_DUMMY, + parent, + "dummy0", + &err, + "av", "platypus", + NULL)); + + g_assert(err == NULL); + g_assert(dobj->av == DUMMY_PLATYPUS); + + val = object_property_get_enum(OBJECT(dobj), + "av", + "DummyAnimal", + &err); + g_assert(err == NULL); + g_assert(val == DUMMY_PLATYPUS); + + /* A bad enum type name */ + val = object_property_get_enum(OBJECT(dobj), + "av", + "BadAnimal", + &err); + g_assert(err != NULL); + error_free(err); + err = NULL; + + /* A non-enum property name */ + val = object_property_get_enum(OBJECT(dobj), + "iv", + "DummyAnimal", + &err); + g_assert(err != NULL); + error_free(err); +} + + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -254,6 +296,7 @@ int main(int argc, char **argv) g_test_add_func("/qom/proplist/createlist", test_dummy_createlist); g_test_add_func("/qom/proplist/createv", test_dummy_createv); g_test_add_func("/qom/proplist/badenum", test_dummy_badenum); + g_test_add_func("/qom/proplist/getenum", test_dummy_getenum); return g_test_run(); } -- cgit v1.2.1