From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjPKx-0002MR-M5 for qemu-devel@nongnu.org; Mon, 12 Sep 2016 07:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjPKt-00028o-G4 for qemu-devel@nongnu.org; Mon, 12 Sep 2016 07:23:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47186) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjPKt-00028b-AJ for qemu-devel@nongnu.org; Mon, 12 Sep 2016 07:23:39 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6D618123D for ; Mon, 12 Sep 2016 11:23:38 +0000 (UTC) From: Markus Armbruster References: <20160912091913.15831-1-marcandre.lureau@redhat.com> <20160912091913.15831-15-marcandre.lureau@redhat.com> Date: Mon, 12 Sep 2016 13:23:36 +0200 In-Reply-To: <20160912091913.15831-15-marcandre.lureau@redhat.com> (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Mon, 12 Sep 2016 13:19:09 +0400") Message-ID: <87k2eh2wg7.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v6 14/18] tests: add a test to check invalid args List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel@nongnu.org Marc-Andr=C3=A9 Lureau writes: > Check that invalid args on commands without arguments returns an error. > > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > 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); > } >=20=20 > +static void test_qga_invalid_args(gconstpointer fix) > +{ > + const TestFixture *fixture =3D fix; > + QDict *ret, *error; > + const gchar *class, *desc; > + > + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-ping', " > + "'arguments': {'foo': 42 }}"); > + g_assert_nonnull(ret); > + > + error =3D qdict_get_qdict(ret, "error"); > + class =3D qdict_get_try_str(error, "class"); > + desc =3D qdict_get_try_str(error, "desc"); > + > + g_assert_cmpstr(class, =3D=3D, "GenericError"); > + g_assert_cmpstr(desc, =3D=3D, "QMP input object member 'foo' is unex= pected"); 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 =3D fix; > @@ -911,6 +931,7 @@ int main(int argc, char **argv) > g_test_add_data_func("/qga/file-write-read", &fix, test_qga_file_wri= te_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_arg= s); > g_test_add_data_func("/qga/fsfreeze-status", &fix, > test_qga_fsfreeze_status);