diff mbox series

[01/10] qemu-iotests: make execution of tests agnostic to test type

Message ID 20171116173810.16457-2-crosa@redhat.com
State New
Headers show
Series I/O tests cleanups | expand

Commit Message

Cleber Rosa Nov. 16, 2017, 5:38 p.m. UTC
check makes a distinction on how it runs Python based tests.  The
current approach is inconsistent because:

1) a large number of Python tests are already set as executable files
(eg: 030, 040, 041, 044, 045, 055, 056, 057, 065, 093, 118, 147, 149,
155, 165 and 194)

2) a smaller number of Python tests are not set as executable files

3) the true purpose of a shebang line is to make a file executable,
while it currently is used (inconsistently) as a test type flag

4) the same logic could in theory be applied to shell based tests,
that is, if first line contains a shell shebang, run it with
"$SHELL $test_file", but it'd be pointless

IMO, there's no value in the distinction that check makes.  Dropping
this distinction makes the interface simpler: check requires an
executable file.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 tests/qemu-iotests/096   | 0
 tests/qemu-iotests/124   | 0
 tests/qemu-iotests/129   | 0
 tests/qemu-iotests/132   | 0
 tests/qemu-iotests/136   | 0
 tests/qemu-iotests/139   | 0
 tests/qemu-iotests/148   | 0
 tests/qemu-iotests/152   | 0
 tests/qemu-iotests/163   | 0
 tests/qemu-iotests/check | 9 ++-------
 10 files changed, 2 insertions(+), 7 deletions(-)
 mode change 100644 => 100755 tests/qemu-iotests/096
 mode change 100644 => 100755 tests/qemu-iotests/124
 mode change 100644 => 100755 tests/qemu-iotests/129
 mode change 100644 => 100755 tests/qemu-iotests/132
 mode change 100644 => 100755 tests/qemu-iotests/136
 mode change 100644 => 100755 tests/qemu-iotests/139
 mode change 100644 => 100755 tests/qemu-iotests/148
 mode change 100644 => 100755 tests/qemu-iotests/152
 mode change 100644 => 100755 tests/qemu-iotests/163

Comments

Paolo Bonzini Nov. 17, 2017, 7:25 a.m. UTC | #1
On 16/11/2017 18:38, Cleber Rosa wrote:
> check makes a distinction on how it runs Python based tests.  The
> current approach is inconsistent because:
> 
> 1) a large number of Python tests are already set as executable files
> (eg: 030, 040, 041, 044, 045, 055, 056, 057, 065, 093, 118, 147, 149,
> 155, 165 and 194)
> 
> 2) a smaller number of Python tests are not set as executable files
> 
> 3) the true purpose of a shebang line is to make a file executable,
> while it currently is used (inconsistently) as a test type flag
> 
> 4) the same logic could in theory be applied to shell based tests,
> that is, if first line contains a shell shebang, run it with
> "$SHELL $test_file", but it'd be pointless
> 
> IMO, there's no value in the distinction that check makes.  Dropping
> this distinction makes the interface simpler: check requires an
> executable file.
> 
> Signed-off-by: Cleber Rosa <crosa@redhat.com>

This is quirky, but I think it makes sense to obey the configure
script's chosen Python interpreter.  Unlike /bin/sh or /bin/bash, there
can be many Python interpreters on a system and the user may not want
the one in /usr/bin/python (think of old RHEL with software collections,
even though our use of Python is generally portable to older versions).

I'd keep it for now; in the longer term, we should set up a virtual
environment so that the shebang line does the right thing.

However, making files executable is certainly a good idea.

Thanks,

Paolo


> ---
>  tests/qemu-iotests/096   | 0
>  tests/qemu-iotests/124   | 0
>  tests/qemu-iotests/129   | 0
>  tests/qemu-iotests/132   | 0
>  tests/qemu-iotests/136   | 0
>  tests/qemu-iotests/139   | 0
>  tests/qemu-iotests/148   | 0
>  tests/qemu-iotests/152   | 0
>  tests/qemu-iotests/163   | 0
>  tests/qemu-iotests/check | 9 ++-------
>  10 files changed, 2 insertions(+), 7 deletions(-)
>  mode change 100644 => 100755 tests/qemu-iotests/096
>  mode change 100644 => 100755 tests/qemu-iotests/124
>  mode change 100644 => 100755 tests/qemu-iotests/129
>  mode change 100644 => 100755 tests/qemu-iotests/132
>  mode change 100644 => 100755 tests/qemu-iotests/136
>  mode change 100644 => 100755 tests/qemu-iotests/139
>  mode change 100644 => 100755 tests/qemu-iotests/148
>  mode change 100644 => 100755 tests/qemu-iotests/152
>  mode change 100644 => 100755 tests/qemu-iotests/163
> 
> diff --git a/tests/qemu-iotests/096 b/tests/qemu-iotests/096
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/132 b/tests/qemu-iotests/132
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/148 b/tests/qemu-iotests/148
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/152 b/tests/qemu-iotests/152
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
> old mode 100644
> new mode 100755
> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
> index e6b6ff7a04..08741328d0 100755
> --- a/tests/qemu-iotests/check
> +++ b/tests/qemu-iotests/check
> @@ -741,20 +741,15 @@ do
>          start=`_wallclock`
>          $timestamp && printf %s "        [$(date "+%T")]"
>  
> -        if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
> -            run_command="$PYTHON $seq"
> -        else
> -            run_command="./$seq"
> -        fi
>          export OUTPUT_DIR=$PWD
>          if $debug; then
>              (cd "$source_iotests";
>              MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
> -                    $run_command -d 2>&1 | tee $tmp.out)
> +                    ./$seq -d 2>&1 | tee $tmp.out)
>          else
>              (cd "$source_iotests";
>              MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
> -                    $run_command >$tmp.out 2>&1)
> +                    ./$seq >$tmp.out 2>&1)
>          fi
>          sts=$?
>          $timestamp && _timestamp
>
Cleber Rosa Nov. 17, 2017, 1:15 p.m. UTC | #2
On 11/17/2017 02:25 AM, Paolo Bonzini wrote:
> On 16/11/2017 18:38, Cleber Rosa wrote:
>> check makes a distinction on how it runs Python based tests.  The
>> current approach is inconsistent because:
>>
>> 1) a large number of Python tests are already set as executable files
>> (eg: 030, 040, 041, 044, 045, 055, 056, 057, 065, 093, 118, 147, 149,
>> 155, 165 and 194)
>>
>> 2) a smaller number of Python tests are not set as executable files
>>
>> 3) the true purpose of a shebang line is to make a file executable,
>> while it currently is used (inconsistently) as a test type flag
>>
>> 4) the same logic could in theory be applied to shell based tests,
>> that is, if first line contains a shell shebang, run it with
>> "$SHELL $test_file", but it'd be pointless
>>
>> IMO, there's no value in the distinction that check makes.  Dropping
>> this distinction makes the interface simpler: check requires an
>> executable file.
>>
>> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> 
> This is quirky, but I think it makes sense to obey the configure
> script's chosen Python interpreter.  Unlike /bin/sh or /bin/bash, there
> can be many Python interpreters on a system and the user may not want
> the one in /usr/bin/python (think of old RHEL with software collections,
> even though our use of Python is generally portable to older versions).
> 

Yes, that's a valid point.  Looking at it closer, we usually get "python
-B" from configure, so this changes the behavior (can plague the
developer box with .pyc files).

> I'd keep it for now; in the longer term, we should set up a virtual
> environment so that the shebang line does the right thing.
> 

Agreed.

> However, making files executable is certainly a good idea.
> 
> Thanks,
> 
> Paolo
> 

Thanks for the review,
- Cleber.

> 
>> ---
>>  tests/qemu-iotests/096   | 0
>>  tests/qemu-iotests/124   | 0
>>  tests/qemu-iotests/129   | 0
>>  tests/qemu-iotests/132   | 0
>>  tests/qemu-iotests/136   | 0
>>  tests/qemu-iotests/139   | 0
>>  tests/qemu-iotests/148   | 0
>>  tests/qemu-iotests/152   | 0
>>  tests/qemu-iotests/163   | 0
>>  tests/qemu-iotests/check | 9 ++-------
>>  10 files changed, 2 insertions(+), 7 deletions(-)
>>  mode change 100644 => 100755 tests/qemu-iotests/096
>>  mode change 100644 => 100755 tests/qemu-iotests/124
>>  mode change 100644 => 100755 tests/qemu-iotests/129
>>  mode change 100644 => 100755 tests/qemu-iotests/132
>>  mode change 100644 => 100755 tests/qemu-iotests/136
>>  mode change 100644 => 100755 tests/qemu-iotests/139
>>  mode change 100644 => 100755 tests/qemu-iotests/148
>>  mode change 100644 => 100755 tests/qemu-iotests/152
>>  mode change 100644 => 100755 tests/qemu-iotests/163
>>
>> diff --git a/tests/qemu-iotests/096 b/tests/qemu-iotests/096
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/132 b/tests/qemu-iotests/132
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/148 b/tests/qemu-iotests/148
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/152 b/tests/qemu-iotests/152
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
>> old mode 100644
>> new mode 100755
>> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
>> index e6b6ff7a04..08741328d0 100755
>> --- a/tests/qemu-iotests/check
>> +++ b/tests/qemu-iotests/check
>> @@ -741,20 +741,15 @@ do
>>          start=`_wallclock`
>>          $timestamp && printf %s "        [$(date "+%T")]"
>>  
>> -        if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
>> -            run_command="$PYTHON $seq"
>> -        else
>> -            run_command="./$seq"
>> -        fi
>>          export OUTPUT_DIR=$PWD
>>          if $debug; then
>>              (cd "$source_iotests";
>>              MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
>> -                    $run_command -d 2>&1 | tee $tmp.out)
>> +                    ./$seq -d 2>&1 | tee $tmp.out)
>>          else
>>              (cd "$source_iotests";
>>              MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
>> -                    $run_command >$tmp.out 2>&1)
>> +                    ./$seq >$tmp.out 2>&1)
>>          fi
>>          sts=$?
>>          $timestamp && _timestamp
>>
> 
>
Max Reitz Dec. 1, 2017, 8:16 p.m. UTC | #3
On 2017-11-17 14:15, Cleber Rosa wrote:
> 
> 
> On 11/17/2017 02:25 AM, Paolo Bonzini wrote:
>> On 16/11/2017 18:38, Cleber Rosa wrote:
>>> check makes a distinction on how it runs Python based tests.  The
>>> current approach is inconsistent because:
>>>
>>> 1) a large number of Python tests are already set as executable files
>>> (eg: 030, 040, 041, 044, 045, 055, 056, 057, 065, 093, 118, 147, 149,
>>> 155, 165 and 194)
>>>
>>> 2) a smaller number of Python tests are not set as executable files
>>>
>>> 3) the true purpose of a shebang line is to make a file executable,
>>> while it currently is used (inconsistently) as a test type flag
>>>
>>> 4) the same logic could in theory be applied to shell based tests,
>>> that is, if first line contains a shell shebang, run it with
>>> "$SHELL $test_file", but it'd be pointless
>>>
>>> IMO, there's no value in the distinction that check makes.  Dropping
>>> this distinction makes the interface simpler: check requires an
>>> executable file.
>>>
>>> Signed-off-by: Cleber Rosa <crosa@redhat.com>
>>
>> This is quirky, but I think it makes sense to obey the configure
>> script's chosen Python interpreter.  Unlike /bin/sh or /bin/bash, there
>> can be many Python interpreters on a system and the user may not want
>> the one in /usr/bin/python (think of old RHEL with software collections,
>> even though our use of Python is generally portable to older versions).
>>
> 
> Yes, that's a valid point.  Looking at it closer, we usually get "python
> -B" from configure, so this changes the behavior (can plague the
> developer box with .pyc files).

Not just that, the most important thing is that you get python2 on
systems where /usr/bin/python points to python3 (i.e., Arch).

Max
diff mbox series

Patch

diff --git a/tests/qemu-iotests/096 b/tests/qemu-iotests/096
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/129 b/tests/qemu-iotests/129
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/132 b/tests/qemu-iotests/132
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/148 b/tests/qemu-iotests/148
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/152 b/tests/qemu-iotests/152
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
old mode 100644
new mode 100755
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index e6b6ff7a04..08741328d0 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -741,20 +741,15 @@  do
         start=`_wallclock`
         $timestamp && printf %s "        [$(date "+%T")]"
 
-        if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
-            run_command="$PYTHON $seq"
-        else
-            run_command="./$seq"
-        fi
         export OUTPUT_DIR=$PWD
         if $debug; then
             (cd "$source_iotests";
             MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
-                    $run_command -d 2>&1 | tee $tmp.out)
+                    ./$seq -d 2>&1 | tee $tmp.out)
         else
             (cd "$source_iotests";
             MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \
-                    $run_command >$tmp.out 2>&1)
+                    ./$seq >$tmp.out 2>&1)
         fi
         sts=$?
         $timestamp && _timestamp