qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/7] iotests: Allow out-of-tree run
Date: Thu, 15 May 2014 16:52:22 -0600	[thread overview]
Message-ID: <53754526.5090407@redhat.com> (raw)
In-Reply-To: <1400192774-606-2-git-send-email-mreitz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2254 bytes --]

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 through
> a symlink, and if so, will assume it is run in the build tree. All
> output and temporary operations performed by iotests are then redirected
> here and, unless specified otherwise by the user, QEMU_PROG etc. will be
> set to paths appropriate for the build tree.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/check         | 78 ++++++++++++++++++++++++++++++++++------

>  
> +if [ -L "$0" ]
> +then
> +    # called from the build tree
> +    source_iotests="$(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 => true) or as ! { '(' -o ')' } (! (true
-o true) => 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=1; exit
>      fi
>  
> -    (eval "echo '---' \"$_cmd\"") >>$here/$seq.full
> +    (eval "echo '---' \"$_cmd\"") >>"$OUTPUT_DIR/$seq.full"
>      (eval "$_cmd") >$tmp._out 2>&1; ret=$?

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.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-05-15 22:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 22:26 [Qemu-devel] [PATCH 0/7] iotests: Allow out-of-tree run Max Reitz
2014-05-15 22:26 ` [Qemu-devel] [PATCH 1/7] " Max Reitz
2014-05-15 22:52   ` Eric Blake [this message]
2014-05-16 14:43     ` Max Reitz
2014-05-16 15:09       ` Eric Blake
2014-05-16 15:11         ` Max Reitz
2014-05-15 22:26 ` [Qemu-devel] [PATCH 2/7] configure: Enable out-of-tree iotests Max Reitz
2014-05-15 22:26 ` [Qemu-devel] [PATCH 3/7] iotests: Add default common.env Max Reitz
2014-05-15 22:26 ` [Qemu-devel] [PATCH 4/7] iotests: Source common.env Max Reitz
2014-05-16  7:40   ` Fam Zheng
2014-05-16 14:49     ` Max Reitz
2014-05-15 22:26 ` [Qemu-devel] [PATCH 5/7] iotests: Use $PYTHON for Python scripts Max Reitz
2014-05-16  7:54   ` Fam Zheng
2014-05-16 14:52     ` Max Reitz
2014-05-15 22:26 ` [Qemu-devel] [PATCH 6/7] iotests: Drop Python version from 065's Shebang Max Reitz
2014-05-15 22:26 ` [Qemu-devel] [PATCH 7/7] iotests: Fix 083 for out-of-tree builds Max Reitz
2014-05-16  8:06 ` [Qemu-devel] [PATCH 0/7] iotests: Allow out-of-tree run Fam Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53754526.5090407@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).