diff mbox series

device-crash-test: Check if path is actually an executable file

Message ID 20201026125238.2752882-1-ehabkost@redhat.com
State New
Headers show
Series device-crash-test: Check if path is actually an executable file | expand

Commit Message

Eduardo Habkost Oct. 26, 2020, 12:52 p.m. UTC
After the transition to Meson, the build directory now have
subdirectories named "qemu-system-*.p", and device-crash-test
will try to execute them as if they were binaries.  This results
in errors like:

  PermissionError: [Errno 13] Permission denied: './qemu-system-or1k.p'

When generating the default list of binaries to test, check if
the path is actually a file and if it's executable.

Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 scripts/device-crash-test | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Thomas Huth Oct. 26, 2020, 1:16 p.m. UTC | #1
On 26/10/2020 13.52, Eduardo Habkost wrote:
> After the transition to Meson, the build directory now have
> subdirectories named "qemu-system-*.p", and device-crash-test
> will try to execute them as if they were binaries.  This results
> in errors like:
> 
>   PermissionError: [Errno 13] Permission denied: './qemu-system-or1k.p'
> 
> When generating the default list of binaries to test, check if
> the path is actually a file and if it's executable.
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  scripts/device-crash-test | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/device-crash-test b/scripts/device-crash-test
> index 866baf7058..04118669ba 100755
> --- a/scripts/device-crash-test
> +++ b/scripts/device-crash-test
> @@ -383,7 +383,9 @@ def binariesToTest(args, testcase):
>      if args.qemu:
>          r = args.qemu
>      else:
> -        r = glob.glob('./qemu-system-*')
> +        r = [f.path for f in os.scandir('.')
> +             if f.name.startswith('qemu-system-') and
> +                f.is_file() and os.access(f, os.X_OK)]
>      return r

Thanks, this seems to fix the issue for me!

Tested-by: Thomas Huth <thuth@redhat.com>
Philippe Mathieu-Daudé Oct. 26, 2020, 1:40 p.m. UTC | #2
On 10/26/20 1:52 PM, Eduardo Habkost wrote:
> After the transition to Meson, the build directory now have
> subdirectories named "qemu-system-*.p", and device-crash-test
> will try to execute them as if they were binaries.  This results
> in errors like:
> 
>    PermissionError: [Errno 13] Permission denied: './qemu-system-or1k.p'
> 
> When generating the default list of binaries to test, check if
> the path is actually a file and if it's executable.
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>   scripts/device-crash-test | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

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

Patch

diff --git a/scripts/device-crash-test b/scripts/device-crash-test
index 866baf7058..04118669ba 100755
--- a/scripts/device-crash-test
+++ b/scripts/device-crash-test
@@ -383,7 +383,9 @@  def binariesToTest(args, testcase):
     if args.qemu:
         r = args.qemu
     else:
-        r = glob.glob('./qemu-system-*')
+        r = [f.path for f in os.scandir('.')
+             if f.name.startswith('qemu-system-') and
+                f.is_file() and os.access(f, os.X_OK)]
     return r