Il 21/12/2012 13:17, Gerd Hoffmann ha scritto: > { 'type': 'ChardevDummy', 'data': { } } > > { 'union': 'ChardevBackend', 'data': { 'file' : 'ChardevFile', > 'port' : 'ChardevPort', > 'socket' : 'ChardevSocket', > 'pty' : 'ChardevDummy', > 'null' : 'ChardevDummy' } } > > { 'command': 'chardev-add', 'data': {'id' : 'str', > 'backend' : 'ChardevBackend' }, > > ... should accept ... > > {'id': 'test-null', 'backend': {'data': {}, 'type': 'null'}} > > ... as parameters for chardev-add, no? But I get back ... > > {u'error': {u'class': u'GenericError', u'desc': u"Invalid parameter > 'backend'"}} > > ... and can't see what is wrong there ...
Me neither, but this quick test seems to work here: $ tests/test-qmp-commands /gerd: test-null 1 OK diff --git a/qapi-schema-test.json b/qapi-schema-test.json index 9eae350..c2e9316 100644 --- a/qapi-schema-test.json +++ b/qapi-schema-test.json @@ -36,3 +36,12 @@ { 'command': 'user_def_cmd', 'data': {} } { 'command': 'user_def_cmd1', 'data': {'ud1a': 'UserDefOne'} } { 'command': 'user_def_cmd2', 'data': {'ud1a': 'UserDefOne', 'ud1b': 'UserDefOne'}, 'returns': 'UserDefTwo' } + + +{ 'type': 'ChardevDummy', 'data': { } } + +{ 'union': 'ChardevBackend', 'data': { 'pty' : 'ChardevDummy', + 'null' : 'ChardevDummy' } } + +{ 'command': 'chardev-add', 'data': {'id' : 'str', + 'backend' : 'ChardevBackend' } } diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 5a3e82a..96396db 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -55,6 +55,11 @@ static void test_dispatch_cmd(void) QDECREF(req); } +void qmp_chardev_add(const char *id, ChardevBackend *backend, Error **errp) +{ + printf("%s %d\n", id, backend->kind); +} + /* test commands that return an error due to invalid parameters */ static void test_dispatch_cmd_error(void) { @@ -71,6 +76,20 @@ static void test_dispatch_cmd_error(void) QDECREF(req); } +static void test_dispatch_gerd(void) +{ + QObject *req = qobject_from_json( + "{'execute': 'chardev-add', " + " 'arguments': {'id': 'test-null', " + " 'backend': {'data': {}, 'type': 'null'}}} "); + QObject *resp = qmp_dispatch(req); + assert(resp != NULL); + assert(!qdict_haskey(qobject_to_qdict(resp), "error")); + + qobject_decref(resp); + qobject_decref(req); +} + /* test commands that involve both input parameters and return values */ static void test_dispatch_cmd_io(void) { @@ -174,6 +193,7 @@ int main(int argc, char **argv) g_test_add_func("/0.15/dispatch_cmd_io", test_dispatch_cmd_io); g_test_add_func("/0.15/dealloc_types", test_dealloc_types); g_test_add_func("/0.15/dealloc_partial", test_dealloc_partial); + g_test_add_func("/gerd", test_dispatch_gerd); module_call_init(MODULE_INIT_QAPI); g_test_run(); Paolo