From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCqjj-0005RF-PK for qemu-devel@nongnu.org; Fri, 02 Dec 2016 11:31:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCqji-0000z7-P6 for qemu-devel@nongnu.org; Fri, 02 Dec 2016 11:30:59 -0500 References: <1477928314-11184-1-git-send-email-famz@redhat.com> <1477928314-11184-15-git-send-email-famz@redhat.com> From: Max Reitz Message-ID: Date: Fri, 2 Dec 2016 17:30:48 +0100 MIME-Version: 1.0 In-Reply-To: <1477928314-11184-15-git-send-email-famz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mX4IL9Knm6gjcqMlVr509lkNl3wc46TM7" Subject: Re: [Qemu-devel] [PATCH 14/14] tests: Add test-image-lock List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: "Daniel P. Berrange" , Kevin Wolf , qemu-block@nongnu.org, rjones@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --mX4IL9Knm6gjcqMlVr509lkNl3wc46TM7 From: Max Reitz To: Fam Zheng , qemu-devel@nongnu.org Cc: "Daniel P. Berrange" , Kevin Wolf , qemu-block@nongnu.org, rjones@redhat.com Message-ID: Subject: Re: [PATCH 14/14] tests: Add test-image-lock References: <1477928314-11184-1-git-send-email-famz@redhat.com> <1477928314-11184-15-git-send-email-famz@redhat.com> In-Reply-To: <1477928314-11184-15-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 31.10.2016 16:38, Fam Zheng wrote: > Signed-off-by: Fam Zheng > --- > tests/Makefile.include | 2 + > tests/test-image-lock.c | 179 ++++++++++++++++++++++++++++++++++++++++= ++++++++ > 2 files changed, 181 insertions(+) > create mode 100644 tests/test-image-lock.c >=20 > diff --git a/tests/Makefile.include b/tests/Makefile.include > index cd058ef..65f8500 100644 > --- a/tests/Makefile.include > +++ b/tests/Makefile.include > @@ -56,6 +56,7 @@ check-unit-y +=3D tests/test-hbitmap$(EXESUF) > gcov-files-test-hbitmap-y =3D blockjob.c > check-unit-y +=3D tests/test-blockjob$(EXESUF) > check-unit-y +=3D tests/test-blockjob-txn$(EXESUF) > +check-unit-y +=3D tests/test-image-lock$(EXESUF) > check-unit-y +=3D tests/test-x86-cpuid$(EXESUF) > # all code tested by test-x86-cpuid is inside topology.h > gcov-files-test-x86-cpuid-y =3D > @@ -493,6 +494,7 @@ tests/test-rfifolock$(EXESUF): tests/test-rfifolock= =2Eo $(test-util-obj-y) > tests/test-throttle$(EXESUF): tests/test-throttle.o $(test-block-obj-y= ) > tests/test-blockjob$(EXESUF): tests/test-blockjob.o $(test-block-obj-y= ) $(test-util-obj-y) > tests/test-blockjob-txn$(EXESUF): tests/test-blockjob-txn.o $(test-blo= ck-obj-y) $(test-util-obj-y) > +tests/test-image-lock$(EXESUF): tests/test-image-lock.o $(test-block-o= bj-y) $(libqos-obj-y) > tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block= -obj-y) > tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) > tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) > diff --git a/tests/test-image-lock.c b/tests/test-image-lock.c > new file mode 100644 > index 0000000..db5a723 > --- /dev/null > +++ b/tests/test-image-lock.c > @@ -0,0 +1,179 @@ > +/* > + * Image lock tests > + * > + * Copyright 2016 Red Hat, Inc. > + * > + * Authors: > + * Fam Zheng > + * > + * This work is licensed under the terms of the GNU LGPL, version 2 or= later. > + * See the COPYING.LIB file in the top-level directory. > + */ > + > +#include "qemu/osdep.h" > +#include "qapi/error.h" > +#include "qemu/error-report.h" > +#include "qapi/qmp/qbool.h" > +#include "sysemu/block-backend.h" > + > +#define TEST_IMAGE_SIZE 4096 > +static char test_image[] =3D "/tmp/qtest.XXXXXX"; > +static int test_image_fd; > + > +static BlockBackend *open_test_image(int flags, bool disable_lock) > +{ > + QDict *opts =3D qdict_new(); > + > + qdict_set_default_str(opts, "filename", test_image); > + qdict_set_default_str(opts, "driver", "file"); > + if (disable_lock) { > + qdict_put(opts, "disable-lock", qbool_from_bool(true)); > + } > + > + return blk_new_open(NULL, NULL, opts, flags | BDRV_O_ALLOW_RDWR, N= ULL); > +} > + > +#define RW true > +#define RO false > +#define SHARE true > +#define EXCLU false > + > +static struct CompatData { > + bool write_1; > + bool share_1; > + bool write_2; > + bool share_2; > + bool compatible; > +} compat_data[] =3D { > + /* Write 1, Share 1, Write 2, Share 2, Compatible. */ > + { RO, SHARE, RO, SHARE, true, }, > + { RO, SHARE, RO, EXCLU, true, }, > + { RO, SHARE, RW, SHARE, true, }, > + { RO, SHARE, RW, EXCLU, true, }, > + { RO, EXCLU, RO, SHARE, true, }, > + { RO, EXCLU, RO, EXCLU, true, }, > + { RO, EXCLU, RW, SHARE, false, }, > + { RO, EXCLU, RW, EXCLU, false, }, > +}; Without having looked closer at the test, what about RW/RW compatibility?= Max --mX4IL9Knm6gjcqMlVr509lkNl3wc46TM7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQFGBAEBCAAwFiEEkb62CjDbPohX0Rgp9AfbAGHVz0AFAlhBobgSHG1yZWl0ekBy ZWRoYXQuY29tAAoJEPQH2wBh1c9AsWcIAJUHBZwT8WKbD1pOC8lutqUSpMgAQUNp uEOYGkvUyiaPaf8VRDywlSJ1rrEGIe7D1gZr13y7UM7kW6dV8FnL1W7cK7VLtcAC rfJCWpvt+fCHNju0h6WqJ6fcZWruGCKeAfsyfzZ1iUxfWoZ1zTWWITEz2DMq0u0W pb1XX49CcOV4reoO6nWSVbGQAVdMsiZhNuLSLTlxoKXNFBLCHNgbX9rmkBi79Mzv yRRaSvxT51DGJjCkPw1BDLZVkWyrkr6JMTddSGun6aHFHr8Q6+3wKdgZFRaERL7b rsqElHlawhOvYsL5Qpb5suWQ/5t0qNMBbXfA53WfqSULKjPDHENKmc8= =fXet -----END PGP SIGNATURE----- --mX4IL9Knm6gjcqMlVr509lkNl3wc46TM7--