qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH] iotests: Allow running from different directory
Date: Thu, 3 Sep 2020 19:21:46 +0200	[thread overview]
Message-ID: <20200903172146.GF8835@linux.fritz.box> (raw)
In-Reply-To: <170e9e09-5d81-f75b-fbb1-b60ed0d2e776@redhat.com>

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

Am 03.09.2020 um 14:54 hat Max Reitz geschrieben:
> On 02.09.20 13:03, Kevin Wolf wrote:
> > It is convenient to be able to edit the tests and run them without
> > changing the current working directory back and forth. Instead of
> > assuming that $PWD is the qemu-iotests build directory, derive the build
> > directory from the executed script.
> > 
> > This allows 'check' to find the required files even when called from
> > another directory. The scratch directory will still be in the current
> > working directory.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  tests/qemu-iotests/check | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
> > index 3ab859ac1a..22ada6a549 100755
> > --- a/tests/qemu-iotests/check
> > +++ b/tests/qemu-iotests/check
> > @@ -44,7 +44,7 @@ then
> >          _init_error "failed to obtain source tree name from check symlink"
> >      fi
> >      source_iotests=$(cd "$source_iotests"; pwd) || _init_error "failed to enter source tree"
> > -    build_iotests=$PWD
> > +    build_iotests=$(dirname "$0")
> 
> This breaks running check from the build tree.
> (i.e. cd $build/tests/qemu-iotests; ./check)
> 
> The problem is that to run the test, we do cd to the source directory
> ($source_iotests), and so $build_iotests then becomes invalid if it’s
> just a relative path.  In my case, this leads to the following error:
> 
> -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
> +./common.rc: line 139: $QEMU/tests/qemu-iotests/../../qemu-img: No such
> file or directory

Ah, my symlinks in the source tree made it work for me.

> I think this could be resolved by wrapping the $(dirname) in
> $(realpath), i.e.
> 
> build_iotests=$(realpath "$(dirname "$0")")

Sounds good, I'll update it in my tree.

Kevin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-09-03 17:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 11:03 [PATCH] iotests: Allow running from different directory Kevin Wolf
2020-09-02 11:07 ` Claudio Fontana
2020-09-03 12:54 ` Max Reitz
2020-09-03 17:21   ` Kevin Wolf [this message]
2020-09-12 22:28     ` Claudio Fontana

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=20200903172146.GF8835@linux.fritz.box \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).