[Qemu-devel] [PATCH 3/6] tests/qemu-iotests: Do not hard-code the path to bash

Thomas Huth posted 6 patches 6 years, 9 months ago
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Li-Wen Hsu <lwhsu@freebsd.org>, Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>, Max Reitz <mreitz@redhat.com>, Ed Maste <emaste@freebsd.org>
There is a newer version of this series
[Qemu-devel] [PATCH 3/6] tests/qemu-iotests: Do not hard-code the path to bash
Posted by Thomas Huth 6 years, 9 months ago
bash is installed in a different directory on non-Linux systems like
FreeBSD. Do not hard-code /bin/bash here so that the tests can run
there, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qemu-iotests/239 | 2 +-
 tests/qemu-iotests/240 | 2 +-
 tests/qemu-iotests/241 | 2 +-
 tests/qemu-iotests/243 | 2 +-
 tests/qemu-iotests/244 | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/qemu-iotests/239 b/tests/qemu-iotests/239
index 6f085d573d..b0991ffe59 100755
--- a/tests/qemu-iotests/239
+++ b/tests/qemu-iotests/239
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Test case for dmg
 #
diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
index 65cc3b39b1..d3e663ed65 100755
--- a/tests/qemu-iotests/240
+++ b/tests/qemu-iotests/240
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Test hot plugging and unplugging with iothreads
 #
diff --git a/tests/qemu-iotests/241 b/tests/qemu-iotests/241
index 017a736aab..58b64ebf41 100755
--- a/tests/qemu-iotests/241
+++ b/tests/qemu-iotests/241
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Test qemu-nbd vs. unaligned images
 #
diff --git a/tests/qemu-iotests/243 b/tests/qemu-iotests/243
index 5838c6e89c..e563761307 100755
--- a/tests/qemu-iotests/243
+++ b/tests/qemu-iotests/243
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Test qcow2 preallocation
 #
diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244
index d8e7122305..13978f93d2 100755
--- a/tests/qemu-iotests/244
+++ b/tests/qemu-iotests/244
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Test qcow2 with external data files
 #
-- 
2.21.0


Re: [Qemu-devel] [PATCH 3/6] tests/qemu-iotests: Do not hard-code the path to bash
Posted by Eric Blake 6 years, 9 months ago
On 4/24/19 5:37 AM, Thomas Huth wrote:
> bash is installed in a different directory on non-Linux systems like
> FreeBSD. Do not hard-code /bin/bash here so that the tests can run
> there, too.

These tests were obviously copy-and-pasted from a fork point prior to
commit 11a82d14.

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/qemu-iotests/239 | 2 +-
>  tests/qemu-iotests/240 | 2 +-
>  tests/qemu-iotests/241 | 2 +-
>  tests/qemu-iotests/243 | 2 +-
>  tests/qemu-iotests/244 | 2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [PATCH 3/6] tests/qemu-iotests: Do not hard-code the path to bash
Posted by Philippe Mathieu-Daudé 6 years, 9 months ago
On 4/24/19 4:14 PM, Eric Blake wrote:
> On 4/24/19 5:37 AM, Thomas Huth wrote:
>> bash is installed in a different directory on non-Linux systems like
>> FreeBSD. Do not hard-code /bin/bash here so that the tests can run
>> there, too.
> 
> These tests were obviously copy-and-pasted from a fork point prior to
> commit 11a82d14.

:(

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>  tests/qemu-iotests/239 | 2 +-
>>  tests/qemu-iotests/240 | 2 +-
>>  tests/qemu-iotests/241 | 2 +-
>>  tests/qemu-iotests/243 | 2 +-
>>  tests/qemu-iotests/244 | 2 +-
>>  5 files changed, 5 insertions(+), 5 deletions(-)
> 
> 

Re: [Qemu-devel] [PATCH 3/6] tests/qemu-iotests: Do not hard-code the path to bash
Posted by Daniel P. Berrangé 6 years, 9 months ago
On Wed, Apr 24, 2019 at 09:14:29AM -0500, Eric Blake wrote:
> On 4/24/19 5:37 AM, Thomas Huth wrote:
> > bash is installed in a different directory on non-Linux systems like
> > FreeBSD. Do not hard-code /bin/bash here so that the tests can run
> > there, too.
> 
> These tests were obviously copy-and-pasted from a fork point prior to
> commit 11a82d14.

Is this a candidate for a checkpatch addition to reject any use
of /bin/bash in scripts ?

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH 3/6] tests/qemu-iotests: Do not hard-code the path to bash
Posted by Thomas Huth 6 years, 9 months ago
On 24/04/2019 17.23, Daniel P. Berrangé wrote:
> On Wed, Apr 24, 2019 at 09:14:29AM -0500, Eric Blake wrote:
>> On 4/24/19 5:37 AM, Thomas Huth wrote:
>>> bash is installed in a different directory on non-Linux systems like
>>> FreeBSD. Do not hard-code /bin/bash here so that the tests can run
>>> there, too.
>>
>> These tests were obviously copy-and-pasted from a fork point prior to
>> commit 11a82d14.
> 
> Is this a candidate for a checkpatch addition to reject any use
> of /bin/bash in scripts ?

Not sure whether we should really reject it with an error (there might
be scripts that are only used on Linux anyway), but checkpatch.pl should
at least print a warning, I think.

 Thomas

Re: [Qemu-devel] [PATCH 3/6] tests/qemu-iotests: Do not hard-code the path to bash
Posted by Alex Bennée 6 years, 9 months ago
Thomas Huth <thuth@redhat.com> writes:

> bash is installed in a different directory on non-Linux systems like
> FreeBSD. Do not hard-code /bin/bash here so that the tests can run
> there, too.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  tests/qemu-iotests/239 | 2 +-
>  tests/qemu-iotests/240 | 2 +-
>  tests/qemu-iotests/241 | 2 +-
>  tests/qemu-iotests/243 | 2 +-
>  tests/qemu-iotests/244 | 2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tests/qemu-iotests/239 b/tests/qemu-iotests/239
> index 6f085d573d..b0991ffe59 100755
> --- a/tests/qemu-iotests/239
> +++ b/tests/qemu-iotests/239
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  #
>  # Test case for dmg
>  #
> diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
> index 65cc3b39b1..d3e663ed65 100755
> --- a/tests/qemu-iotests/240
> +++ b/tests/qemu-iotests/240
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  #
>  # Test hot plugging and unplugging with iothreads
>  #
> diff --git a/tests/qemu-iotests/241 b/tests/qemu-iotests/241
> index 017a736aab..58b64ebf41 100755
> --- a/tests/qemu-iotests/241
> +++ b/tests/qemu-iotests/241
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  #
>  # Test qemu-nbd vs. unaligned images
>  #
> diff --git a/tests/qemu-iotests/243 b/tests/qemu-iotests/243
> index 5838c6e89c..e563761307 100755
> --- a/tests/qemu-iotests/243
> +++ b/tests/qemu-iotests/243
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  #
>  # Test qcow2 preallocation
>  #
> diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244
> index d8e7122305..13978f93d2 100755
> --- a/tests/qemu-iotests/244
> +++ b/tests/qemu-iotests/244
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/usr/bin/env bash
>  #
>  # Test qcow2 with external data files
>  #


--
Alex Bennée