diff options
author | Markus Armbruster <armbru@redhat.com> | 2014-03-01 08:40:29 +0100 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2014-03-03 11:16:45 -0500 |
commit | c2216a8a7a587e594f50bebbdf81fcf168444b68 (patch) | |
tree | 71a08dc3a80ba5ae49205b7d380a438eb05d7233 /tests | |
parent | ab22ad96cea4300a92b400b0c46af2f50a037362 (diff) |
tests/qapi-schema: Cover simple argument types
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qapi-schema/qapi-schema-test.json | 2 | ||||
-rw-r--r-- | tests/qapi-schema/qapi-schema-test.out | 1 | ||||
-rw-r--r-- | tests/test-qmp-commands.c | 16 |
3 files changed, 19 insertions, 0 deletions
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json index d2b1397d82..3f62821b60 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -53,6 +53,8 @@ { 'command': 'user_def_cmd2', 'data': {'ud1a': 'UserDefOne', '*ud1b': 'UserDefOne'}, 'returns': 'UserDefTwo' } +{ 'command': 'user_def_cmd3', 'data': {'a': 'int', '*b': 'int' }, + 'returns': 'int' } # For testing integer range flattening in opts-visitor. The following schema # corresponds to the option format: diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out index af9829eaa2..59468ac9a2 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -10,6 +10,7 @@ OrderedDict([('command', 'user_def_cmd'), ('data', OrderedDict())]), OrderedDict([('command', 'user_def_cmd1'), ('data', OrderedDict([('ud1a', 'UserDefOne')]))]), OrderedDict([('command', 'user_def_cmd2'), ('data', OrderedDict([('ud1a', 'UserDefOne'), ('*ud1b', 'UserDefOne')])), ('returns', 'UserDefTwo')]), + OrderedDict([('command', 'user_def_cmd3'), ('data', OrderedDict([('a', 'int'), ('*b', 'int')])), ('returns', 'int')]), OrderedDict([('type', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))])] ['EnumOne', 'UserDefUnionKind', 'UserDefNativeListUnionKind'] [OrderedDict([('type', 'NestedEnumsOne'), ('data', OrderedDict([('enum1', 'EnumOne'), ('*enum2', 'EnumOne'), ('enum3', 'EnumOne'), ('*enum4', 'EnumOne')]))]), diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index d7720ab19d..4586cee37e 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -41,6 +41,11 @@ UserDefTwo *qmp_user_def_cmd2(UserDefOne *ud1a, return ret; } +int64_t qmp_user_def_cmd3(int64_t a, bool has_b, int64_t b, Error **errp) +{ + return a + (has_b ? b : 0); +} + /* test commands with no input and no return value */ static void test_dispatch_cmd(void) { @@ -95,10 +100,12 @@ static void test_dispatch_cmd_io(void) { QDict *req = qdict_new(); QDict *args = qdict_new(); + QDict *args3 = qdict_new(); QDict *ud1a = qdict_new(); QDict *ud1b = qdict_new(); QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef; QDict *ret_dict_dict2, *ret_dict_dict2_userdef; + QInt *ret3; qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42))); qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello"))); @@ -125,6 +132,15 @@ static void test_dispatch_cmd_io(void) assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2")); assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4")); QDECREF(ret); + + qdict_put(args3, "a", qint_from_int(66)); + qdict_put(req, "arguments", args3); + qdict_put(req, "execute", qstring_from_str("user_def_cmd3")); + + ret3 = qobject_to_qint(test_qmp_dispatch(req)); + assert(qint_get_int(ret3) == 66); + QDECREF(ret); + QDECREF(req); } |