diff mbox series

test/py: Improve check for mksquashfs version

Message ID 20210722205205.19540-1-marek.behun@nic.cz
State Accepted
Commit 89795ef3b6b2d12cffb840a98ee374d2e806aa64
Delegated to: Tom Rini
Headers show
Series test/py: Improve check for mksquashfs version | expand

Commit Message

Marek Behún July 22, 2021, 8:52 p.m. UTC
Some builds of squashfs-tools append version string with "-git" or
similar. The float() conversion will fail in this case.

Improve the code to only convert to float() the string before the '-'
character.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 test/py/tests/test_fs/test_squashfs/sqfs_common.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass July 23, 2021, 3:07 a.m. UTC | #1
On Thu, 22 Jul 2021 at 14:52, Marek Behún <marek.behun@nic.cz> wrote:
>
> Some builds of squashfs-tools append version string with "-git" or
> similar. The float() conversion will fail in this case.
>
> Improve the code to only convert to float() the string before the '-'
> character.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  test/py/tests/test_fs/test_squashfs/sqfs_common.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Thanks, I hit that on rpi actually.
João Marcos Costa July 23, 2021, 1 p.m. UTC | #2
Em qui., 22 de jul. de 2021 às 17:52, Marek Behún <marek.behun@nic.cz> escreveu:
>
> Some builds of squashfs-tools append version string with "-git" or
> similar. The float() conversion will fail in this case.
>
> Improve the code to only convert to float() the string before the '-'
> character.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> ---
>  test/py/tests/test_fs/test_squashfs/sqfs_common.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/test/py/tests/test_fs/test_squashfs/sqfs_common.py b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
> index 267c4b57d1..8b84c2cdca 100644
> --- a/test/py/tests/test_fs/test_squashfs/sqfs_common.py
> +++ b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
> @@ -146,7 +146,7 @@ def get_mksquashfs_version():
>      out = subprocess.run(['mksquashfs -version'], shell=True, check=True,
>                           capture_output=True, text=True)
>      # 'out' is: mksquashfs version X (yyyy/mm/dd) ...
> -    return float(out.stdout.split()[2])
> +    return float(out.stdout.split()[2].split('-')[0])
>
>  def check_mksquashfs_version():
>      """ Checks if mksquashfs meets the required version. """
> --
> 2.31.1
>

Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>

Thanks!
Tom Rini July 29, 2021, 4:49 p.m. UTC | #3
On Thu, Jul 22, 2021 at 10:52:05PM +0200, Marek Behún wrote:

> Some builds of squashfs-tools append version string with "-git" or
> similar. The float() conversion will fail in this case.
> 
> Improve the code to only convert to float() the string before the '-'
> character.
> 
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/test/py/tests/test_fs/test_squashfs/sqfs_common.py b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
index 267c4b57d1..8b84c2cdca 100644
--- a/test/py/tests/test_fs/test_squashfs/sqfs_common.py
+++ b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
@@ -146,7 +146,7 @@  def get_mksquashfs_version():
     out = subprocess.run(['mksquashfs -version'], shell=True, check=True,
                          capture_output=True, text=True)
     # 'out' is: mksquashfs version X (yyyy/mm/dd) ...
-    return float(out.stdout.split()[2])
+    return float(out.stdout.split()[2].split('-')[0])
 
 def check_mksquashfs_version():
     """ Checks if mksquashfs meets the required version. """