From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wl4Vr-0003kV-3u for qemu-devel@nongnu.org; Thu, 15 May 2014 18:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wl4Vm-0004P4-2r for qemu-devel@nongnu.org; Thu, 15 May 2014 18:52:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49923) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wl4Vl-0004Ox-Qa for qemu-devel@nongnu.org; Thu, 15 May 2014 18:52:26 -0400 Message-ID: <53754526.5090407@redhat.com> Date: Thu, 15 May 2014 16:52:22 -0600 From: Eric Blake MIME-Version: 1.0 References: <1400192774-606-1-git-send-email-mreitz@redhat.com> <1400192774-606-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1400192774-606-2-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qBbDPmGrU7eh1161owFMw8i8NRo11GH3g" Subject: Re: [Qemu-devel] [PATCH 1/7] iotests: Allow out-of-tree run List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Markus Armbruster , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qBbDPmGrU7eh1161owFMw8i8NRo11GH3g Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/15/2014 04:26 PM, Max Reitz wrote: > As out-of-tree builds are preferred for qemu, running the qemu-iotests > in that out-of-tree build should be supported as well. To do so, a > symbolic link has to be created pointing to the check script in the > source directory. That script will check whether it has been run throug= h > a symlink, and if so, will assume it is run in the build tree. All > output and temporary operations performed by iotests are then redirecte= d > here and, unless specified otherwise by the user, QEMU_PROG etc. will b= e > set to paths appropriate for the build tree. >=20 > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/check | 78 ++++++++++++++++++++++++++++++++= ++------ > =20 > +if [ -L "$0" ] > +then > + # called from the build tree > + source_iotests=3D"$(cd "$(dirname "$(readlink "$0")")"; pwd)" This is potentially dangerous. If readlink or dirname fails, you can invoke cd "" (which on bash is stupidly a no-op instead of an error), and end up calling pwd in the wrong directory. But in the common case it works, so I'm not sure it's worth bending over backwards to make it more robust. > + if [ -n "$arch" -a -x "$build_root/$arch-softmmu/qemu-system-$= arch" ] -a and -o are NOT portable inside []; POSIX strongly discourages their use because they can cause ambiguous parses: Is [ ! '(' -o ')' ] true or false? Depends on whether it was parsed as { ! '(' } -o ')' (false -o true =3D> true) or as ! { '(' -o ')' } (! (true -o true) =3D> false) But this is bash, so you could do: if [[ $arch && -x $build_root/$arch-softmmu/qemu-system-$arch ]] for less typing, and no risk of [] ambiguity. > +++ b/tests/qemu-iotests/common.rc > @@ -318,9 +318,9 @@ _do() > status=3D1; exit > fi > =20 > - (eval "echo '---' \"$_cmd\"") >>$here/$seq.full > + (eval "echo '---' \"$_cmd\"") >>"$OUTPUT_DIR/$seq.full" > (eval "$_cmd") >$tmp._out 2>&1; ret=3D$? Pre-existing, but we're using 'eval'? That's probably a security risk if $_cmd can contain user-controlled text, such as an odd directory name.= --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --qBbDPmGrU7eh1161owFMw8i8NRo11GH3g Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTdUUmAAoJEKeha0olJ0NqrfMH/1AQqzuP3gRD2rXeG+bvLsf6 24vWBjJGMFKrBDxVZ0960Sh1r/Z6xme/LbpuRMBR0bjnqVoVS4MBxZEmU4PqsFGu /uH6SxYP3lhSPNYoFrpDOJecDFQ8MJGRsubQOTDj4LBsr8E4WOw6TADa6hw9ADOf /JNjfN5SDpOoFYdXF7M3vsvJ7cM+6j8MOmwvNFka7gusPZAFB3xfcpKUMg8PJeAf eLO35u8Xa7fHVD8glNbJ37Z9GJX05KpUQYRVaPA6RDWKbZtXH6jXER1O012N9pI7 94htVqGncwXS6fBpVYndpiwLU1CeTGbGNLqzFxYg0122WnUmWMQnFg1chqzOWhQ= =G6OJ -----END PGP SIGNATURE----- --qBbDPmGrU7eh1161owFMw8i8NRo11GH3g--