Received: from eggs.gnu.org ([2001:4830:134:3::10]:39602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm1dZ-0006Jl-GI for qemu-devel@nongnu.org; Mon, 19 Sep 2016 12:41:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bm1dW-0008Ma-Kp for qemu-devel@nongnu.org; Mon, 19 Sep 2016 12:41:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm1dW-0008M8-Eg for qemu-devel@nongnu.org; Mon, 19 Sep 2016 12:41:42 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 ECDBA6840F for ; Mon, 19 Sep 2016 16:41:41 +0000 (UTC) From: Markus Armbruster Date: Mon, 19 Sep 2016 18:41:30 +0200 Message-Id: <1474303294-13952-15-git-send-email-armbru@redhat.com> In-Reply-To: <1474303294-13952-1-git-send-email-armbru@redhat.com> References: <1474303294-13952-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 14/18] tests: add a test to check invalid args List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau Check that invalid args on commands without arguments returns an error. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20160912091913.15831-15-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- 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 +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"); + + 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); =20 --=20 2.5.5