diff mbox

qemu-iotests: Fix error message if which(1) not installed

Message ID 1416278986-17320-1-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng Nov. 18, 2014, 2:49 a.m. UTC
When which(1) is not installed, we complain "perl not found" because
it's the first set_prog_path check. The error message is misleading.

Fix it by adding a check for which(1) in the beginning.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/qemu-iotests/common.config | 2 ++
 1 file changed, 2 insertions(+)

Comments

Eric Blake Nov. 18, 2014, 4:40 a.m. UTC | #1
On 11/17/2014 07:49 PM, Fam Zheng wrote:
> When which(1) is not installed, we complain "perl not found" because
> it's the first set_prog_path check. The error message is misleading.
> 
> Fix it by adding a check for which(1) in the beginning.

Why not instead change set_prog_path to use 'command -v' instead of
'which'?  As this is a bash script, we shouldn't need to shell out to an
optional package for something we can do natively.
diff mbox

Patch

diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
index bd6790b..9674f3a 100644
--- a/tests/qemu-iotests/common.config
+++ b/tests/qemu-iotests/common.config
@@ -73,6 +73,8 @@  _fatal()
     exit 1
 }
 
+which -v &>/dev/null || _fatal "which not found"
+
 export PERL_PROG="`set_prog_path perl`"
 [ "$PERL_PROG" = "" ] && _fatal "perl not found"