From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn48j-0003Nx-0N for qemu-devel@nongnu.org; Thu, 22 Sep 2016 09:34:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn48c-0001JY-4n for qemu-devel@nongnu.org; Thu, 22 Sep 2016 09:34:11 -0400 Date: Thu, 22 Sep 2016 14:34:00 +0100 From: "Daniel P. Berrange" Message-ID: <20160922133400.GP352@redhat.com> Reply-To: "Daniel P. Berrange" References: <20160922130905.4720-1-marcandre.lureau@redhat.com> <20160922130905.4720-4-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160922130905.4720-4-marcandre.lureau@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 3/3] tests: start generic qemu-qmp tests 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, paolo.bonzini@gmail.com, qemu-stable@nongnu.org, eblake@redhat.com, armbru@redhat.com On Thu, Sep 22, 2016 at 05:09:05PM +0400, Marc-Andr=C3=A9 Lureau wrote: > These 2 tests exhibit two qmp bugs fixed by the previous patches. >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > tests/qemu-qmp-test.c | 61 ++++++++++++++++++++++++++++++++++++++++++= ++++++++ Nitpick - we're not 100% perfect, but the most common convention in tests/ is to use 'test-' as the name prefix for files that contain test suites eg test-qemu-qmp.c > tests/Makefile.include | 1 + > 2 files changed, 62 insertions(+) > create mode 100644 tests/qemu-qmp-test.c >=20 > diff --git a/tests/qemu-qmp-test.c b/tests/qemu-qmp-test.c > new file mode 100644 > index 0000000..3cdee59 > --- /dev/null > +++ b/tests/qemu-qmp-test.c > @@ -0,0 +1,61 @@ > +#include "qemu/osdep.h" > +#include "libqtest.h" > + > + > +static void test_object_add_without_props(void) > +{ > + QDict *ret, *error; > + const gchar *class, *desc; > + > + ret =3D qmp("{'execute': 'object-add'," > + " 'arguments': { 'qom-type': 'memory-backend-ram', 'id':= 'ram1' } }"); > + 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, "can't create backend with size 0"); > + > + QDECREF(ret); > +} > + > +static void test_qom_set_without_value(void) > +{ > + QDict *ret, *error; > + const gchar *class, *desc; > + > + ret =3D qmp("{'execute': 'qom-set'," > + " 'arguments': { 'path': '/machine', 'property': 'rtc-ti= me' } }"); > + 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, "Parameter 'value' is missing"); > + > + QDECREF(ret); > +} > + > +int main(int argc, char **argv) > +{ > + int ret; > + > + g_test_init(&argc, &argv, NULL); > + > + qtest_start(""); > + > + qtest_add_func("/qemu-qmp/object-add-without-props", > + test_object_add_without_props); > + qtest_add_func("/qemu-qmp/qom-set-without-value", > + test_qom_set_without_value); > + > + ret =3D g_test_run(); > + > + qtest_end(); > + > + return ret; > +} > diff --git a/tests/Makefile.include b/tests/Makefile.include > index 6052a38..ce7edf8 100644 > --- a/tests/Makefile.include > +++ b/tests/Makefile.include > @@ -296,6 +296,7 @@ check-qtest-xtensaeb-y =3D $(check-qtest-xtensa-y) > check-qtest-s390x-y =3D tests/boot-serial-test$(EXESUF) > =20 > check-qtest-generic-y +=3D tests/qom-test$(EXESUF) > +check-qtest-generic-y +=3D tests/qemu-qmp-test$(EXESUF) > =20 > qapi-schema +=3D alternate-any.json > qapi-schema +=3D alternate-array.json Reviewed-by: Daniel P. Berrange Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|