qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] iotests: Allow running from different directory


From: Max Reitz
Subject: Re: [PATCH] iotests: Allow running from different directory
Date: Thu, 3 Sep 2020 14:54:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

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

I think this could be resolved by wrapping the $(dirname) in
$(realpath), i.e.

build_iotests=$(realpath "$(dirname "$0")")

Max

>  else
>      # called from the source tree
>      source_iotests=$PWD
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]