* [PATCH] iotests: Allow running from different directory @ 2020-09-02 11:03 Kevin Wolf 2020-09-02 11:07 ` Claudio Fontana 2020-09-03 12:54 ` Max Reitz 0 siblings, 2 replies; 5+ messages in thread From: Kevin Wolf @ 2020-09-02 11:03 UTC (permalink / raw) To: qemu-block; +Cc: kwolf, qemu-devel, mreitz 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") else # called from the source tree source_iotests=$PWD -- 2.25.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] iotests: Allow running from different directory 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 1 sibling, 0 replies; 5+ messages in thread From: Claudio Fontana @ 2020-09-02 11:07 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: qemu-devel, mreitz On 9/2/20 1:03 PM, 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") > else > # called from the source tree > source_iotests=$PWD > Like it, thanks! Reviewed-by: Claudio Fontana <cfontana@suse.de> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iotests: Allow running from different directory 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 1 sibling, 1 reply; 5+ messages in thread From: Max Reitz @ 2020-09-03 12:54 UTC (permalink / raw) To: Kevin Wolf, qemu-block; +Cc: qemu-devel [-- Attachment #1.1: Type: text/plain, Size: 1751 bytes --] 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 #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iotests: Allow running from different directory 2020-09-03 12:54 ` Max Reitz @ 2020-09-03 17:21 ` Kevin Wolf 2020-09-12 22:28 ` Claudio Fontana 0 siblings, 1 reply; 5+ messages in thread From: Kevin Wolf @ 2020-09-03 17:21 UTC (permalink / raw) To: Max Reitz; +Cc: qemu-devel, qemu-block [-- 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 --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iotests: Allow running from different directory 2020-09-03 17:21 ` Kevin Wolf @ 2020-09-12 22:28 ` Claudio Fontana 0 siblings, 0 replies; 5+ messages in thread From: Claudio Fontana @ 2020-09-12 22:28 UTC (permalink / raw) To: Kevin Wolf, Max Reitz; +Cc: qemu-devel, qemu-block On 9/3/20 7:21 PM, Kevin Wolf wrote: > 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 > Hello Kevin, the committed patch in master is now (not sure where it changed): diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 3ab859ac1a..e14a1f354d 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=$(readlink -f $(dirname "$0")) else # called from the source tree source_iotests=$PWD ----- This seems to break the MacOS build (Cirrus-ci) though: readlink: illegal option -- f usage: readlink [-n] [file ...] ./check: line 60: /common.env: No such file or directory check: failed to source common.env (make sure the qemu-iotests are run from tests/qemu-iotests in the build tree) gmake: *** [/private/var/folders/3y/l0z1x3693dl_8n0qybp4dqwh0000gn/T/cirrus-ci-build/tests/Makefile.include:144: check-block] Error 1 Exit status: 2 Ciao, Claudio ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-12 22:29 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2020-09-12 22:28 ` Claudio Fontana
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).