summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2015-05-27 16:07:56 +0100
committerAndreas Färber <afaerber@suse.de>2015-06-19 18:42:48 +0200
commita3590dacce94519c1747d8bf423744c6bb7d9941 (patch)
treeb598151b5822753634082f7a634065009281e877 /tests
parenta8e3fbedc827f992657f5670212e854f62ec12ad (diff)
downloadqemu-a3590dacce94519c1747d8bf423744c6bb7d9941.zip
qom: Don't pass string table to object_get_enum() function
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 <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/check-qom-proplist.c43
1 files changed, 43 insertions, 0 deletions
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();
}