Message ID | 20200914141730.90279-1-mreitz@redhat.com |
---|---|
State | New |
Headers | show |
Series | [v2] iotests: Work around failing readlink -f | expand |
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index e14a1f354d..3c9ccc117b 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -44,7 +44,11 @@ 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=$(readlink -f $(dirname "$0")) + build_iotests=$(readlink -f $(dirname "$0") 2>/dev/null) + if [ "$?" -ne 0 ]; then + # Perhaps -f is unsupported, revert to pre-b1cbc33a397 behavior + build_iotests=$PWD + fi else # called from the source tree source_iotests=$PWD
On macOS, (out of the box) readlink does not have -f. If the recent "readlink -f" call introduced by b1cbc33a397 fails, just fall back to the old behavior (which means you can run the iotests only from the build tree, but that worked fine for six years, so it should be fine still). Suppress all error messages, so in case using $PWD works out, we do not cause the user to worry. If it does not work, we will end up printing the following error message anyway: check: failed to source common.env (make sure the qemu-iotests are run from tests/qemu-iotests in the build tree) Following that hint (running check from $build_tree/tests/qemu-iotests) will make it work, and is probably even easier than obtaining a readlink that understands -f. Fixes: b1cbc33a3971b6bb005d5ac3569feae35a71de0f ("iotests: Allow running from different directory") Reported-by: Claudio Fontana <cfontana@suse.de> Reported-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> --- v2: Suppress stderr (as requested and suggested by Peter) --- tests/qemu-iotests/check | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)