Received: from eggs.gnu.org ([2001:4830:134:3::10]:52278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBnOd-0004gn-F3 for qemu-devel@nongnu.org; Thu, 15 Jan 2015 11:36:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBnOH-0000vd-TG for qemu-devel@nongnu.org; Thu, 15 Jan 2015 11:35:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBnOH-0000ue-AR for qemu-devel@nongnu.org; Thu, 15 Jan 2015 11:35:25 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0FGZMWL016972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 15 Jan 2015 11:35:23 -0500 Date: Thu, 15 Jan 2015 16:35:19 +0000 From: Stefan Hajnoczi Message-ID: <20150115163519.GA23569@stefanha-thinkpad.redhat.com> References: <1421300674-18659-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline In-Reply-To: <1421300674-18659-1-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH] qemu-iotests: Fix supported_oses check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 15, 2015 at 01:44:34PM +0800, Fam Zheng wrote: > There is a bug in the recently added sys.platform test and we no longer > run python tests, because "linux2" is the value to compare here. So do a > prefix match, although the python documentation claims Linux is always > linux2. It would be good to mention that the docs explicitly suggest using startswith(). When reviewing this I wasn't sure whether the startswith() comparison is safe, but knowing the Python docs suggest it means I can be sure this patch is correct. > Signed-off-by: Fam Zheng > --- > tests/qemu-iotests/iotests.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py > index 87002e0..4011725 100644 > --- a/tests/qemu-iotests/iotests.py > +++ b/tests/qemu-iotests/iotests.py > @@ -288,7 +288,7 @@ def main(supported_fmts=3D[], supported_oses=3D['linu= x']): > if supported_fmts and (imgfmt not in supported_fmts): > notrun('not suitable for this image format: %s' % imgfmt) > =20 > - if sys.platform not in supported_oses: > + if not any([sys.platform.startswith(x) for x in supported_oses]): > notrun('not suitable for this OS: %s' % sys.platform) Please don't use any(), we've avoided it to stay compatible with old Python interpreters: if True not in [sys.platform.startswith(x) for x in supported_oses]: --/04w6evG8XlLl3ft Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUt+xHAAoJEJykq7OBq3PIQNIH/1YRJrFRPOFSiYO+EoEXL3bX uoETtCWDoIO0yf7ycm2Khj7gdPV8CWAtAA4awR+3h9giapLrkxueQFub5LT9Vwoa e6JvYUclxpxqIZBA19x2uC5VcQywoi6pmsTwN26k8stfc4vQt9MCu0ncHLFtTG9d pjwglMLj9hO4obmOFvW7m4WNI6Yj/yd8sDaPiUH3TzqAitfSXkbCx1VNOj6P4R7r oP67Ij6kDYdvw019NpkTnXNoWK3weTe/xc+ftcrMLCVBXnvWmL/7zPFuwnN4Cz1V NpsHQeKSF1UZJMGqv/EPupqYHuAwBbB0YQWBjCKQMsSDYyhygv+sl6Z+E7Apt38= =Nt9E -----END PGP SIGNATURE----- --/04w6evG8XlLl3ft--