[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 14/18] tests: add a test to check invalid arg
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v6 14/18] tests: add a test to check invalid args |
Date: |
Mon, 12 Sep 2016 13:23:36 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Marc-André Lureau <address@hidden> writes:
> Check that invalid args on commands without arguments returns an error.
>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
> tests/test-qga.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/tests/test-qga.c b/tests/test-qga.c
> index 21f44f8..40af649 100644
> --- a/tests/test-qga.c
> +++ b/tests/test-qga.c
> @@ -198,6 +198,26 @@ static void test_qga_ping(gconstpointer fix)
> QDECREF(ret);
> }
>
> +static void test_qga_invalid_args(gconstpointer fix)
> +{
> + const TestFixture *fixture = fix;
> + QDict *ret, *error;
> + const gchar *class, *desc;
> +
> + ret = qmp_fd(fixture->fd, "{'execute': 'guest-ping', "
> + "'arguments': {'foo': 42 }}");
> + g_assert_nonnull(ret);
> +
> + error = qdict_get_qdict(ret, "error");
> + class = qdict_get_try_str(error, "class");
> + desc = qdict_get_try_str(error, "desc");
> +
> + g_assert_cmpstr(class, ==, "GenericError");
> + g_assert_cmpstr(desc, ==, "QMP input object member 'foo' is unexpected");
We generally refrain from expecting an exact error message in tests, but
this file does it already elsewhere, so no objection.
> +
> + QDECREF(ret);
> +}
> +
> static void test_qga_invalid_cmd(gconstpointer fix)
> {
> const TestFixture *fixture = fix;
> @@ -911,6 +931,7 @@ int main(int argc, char **argv)
> g_test_add_data_func("/qga/file-write-read", &fix,
> test_qga_file_write_read);
> g_test_add_data_func("/qga/get-time", &fix, test_qga_get_time);
> g_test_add_data_func("/qga/invalid-cmd", &fix, test_qga_invalid_cmd);
> + g_test_add_data_func("/qga/invalid-args", &fix, test_qga_invalid_args);
> g_test_add_data_func("/qga/fsfreeze-status", &fix,
> test_qga_fsfreeze_status);
- [Qemu-devel] [PATCH v6 05/18] monitor: register gen:false commands manually, (continued)
- [Qemu-devel] [PATCH v6 05/18] monitor: register gen:false commands manually, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 06/18] qapi: Support unregistering QMP commands, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 07/18] qmp: Hack to keep commands configuration-specific, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 08/18] qapi: export the marshallers, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 10/18] monitor: implement 'qmp_query_commands' without qmp_cmds, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 09/18] monitor: use qmp_find_command() (using generated qapi code), Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 12/18] qapi: remove the "middle" mode, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 11/18] monitor: remove mhandler.cmd_new, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 13/18] qapi: check invalid arguments on no-args commands, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 14/18] tests: add a test to check invalid args, Marc-André Lureau, 2016/09/12
- Re: [Qemu-devel] [PATCH v6 14/18] tests: add a test to check invalid args,
Markus Armbruster <=
- [Qemu-devel] [PATCH v6 16/18] build-sys: remove qmp-commands-old.h, Marc-André Lureau, 2016/09/12
- [Qemu-devel] [PATCH v6 15/18] monitor: use qmp_dispatch(), Marc-André Lureau, 2016/09/12
[Qemu-devel] [PATCH v6 17/18] qmp-commands.hx: fix some styling, Marc-André Lureau, 2016/09/12
[Qemu-devel] [PATCH v6 18/18] Replace qmp-commands.hx by docs/qmp-commands.txt, Marc-André Lureau, 2016/09/12