* [PATCH] fixup! test: py: add TLV integration tests
@ 2025-10-13 12:00 Ahmad Fatoum
2025-10-14 15:26 ` Jonas Rebmann
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-10-13 12:00 UTC (permalink / raw)
To: barebox; +Cc: Jonas Rebmann, Ahmad Fatoum
test: py: tlv: skip when crcmod is missing
TLV tests shouldn't fail the test suite if the dependencies for the
generator scripts are not available.
Therefore, have the script return 127 as specific error code and skip
the test in that case.
While at it, also drop the currently unused import for mkPredefinedCrcFun.
Cc: Jonas Rebmann <jre@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
scripts/bareboxtlv-generator/bareboxtlv-generator.py | 8 +++++++-
test/py/test_tlv.py | 6 +++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/scripts/bareboxtlv-generator/bareboxtlv-generator.py b/scripts/bareboxtlv-generator/bareboxtlv-generator.py
index 5f9285a80630..6174fe91cdd4 100755
--- a/scripts/bareboxtlv-generator/bareboxtlv-generator.py
+++ b/scripts/bareboxtlv-generator/bareboxtlv-generator.py
@@ -2,9 +2,15 @@
import argparse
import struct
+import sys
import yaml
-from crcmod.predefined import mkPredefinedCrcFun
+
+try:
+ from crcmod.predefined import mkPredefinedCrcFun
+except ModuleNotFoundError:
+ print("Error: missing crcmod dependency", file=sys.stderr)
+ sys.exit(127)
_crc32_mpeg = mkPredefinedCrcFun("crc-32-mpeg")
diff --git a/test/py/test_tlv.py b/test/py/test_tlv.py
index 963f3749b33b..79f9f9d01bbb 100644
--- a/test/py/test_tlv.py
+++ b/test/py/test_tlv.py
@@ -2,11 +2,8 @@ import os
import re
import subprocess
from pathlib import Path
-from crcmod.predefined import mkPredefinedCrcFun
from .helper import skip_disabled
-_crc32_mpeg = mkPredefinedCrcFun("crc-32-mpeg")
-
import pytest
@@ -14,6 +11,9 @@ class _TLV_Testdata:
def generator(self, args, check=True):
cmd = [os.sys.executable, str(self.generator_py)] + args
res = subprocess.run(cmd, text=True)
+ if res.returncode == 127:
+ pytest.skip("test skipped due to missing host dependencies")
+
if check and res.returncode != 0:
raise RuntimeError(f"generator failed ({res.returncode}): {res.stdout}\n{res.stderr}")
return res
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fixup! test: py: add TLV integration tests
2025-10-13 12:00 [PATCH] fixup! test: py: add TLV integration tests Ahmad Fatoum
@ 2025-10-14 15:26 ` Jonas Rebmann
0 siblings, 0 replies; 2+ messages in thread
From: Jonas Rebmann @ 2025-10-14 15:26 UTC (permalink / raw)
To: Ahmad Fatoum, barebox
Hi Ahmad
On 2025-10-13 14:00, Ahmad Fatoum wrote:
> test: py: tlv: skip when crcmod is missing
>
> TLV tests shouldn't fail the test suite if the dependencies for the
> generator scripts are not available.
>
> Therefore, have the script return 127 as specific error code and skip
> the test in that case.
>
> While at it, also drop the currently unused import for mkPredefinedCrcFun.
My patch "test: py: add TLV integration tests" intentionally only
changes the test case. I think we should separate those things.
> Cc: Jonas Rebmann <jre@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> scripts/bareboxtlv-generator/bareboxtlv-generator.py | 8 +++++++-
> test/py/test_tlv.py | 6 +++---
> 2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/bareboxtlv-generator/bareboxtlv-generator.py b/scripts/bareboxtlv-generator/bareboxtlv-generator.py
> index 5f9285a80630..6174fe91cdd4 100755
> --- a/scripts/bareboxtlv-generator/bareboxtlv-generator.py
> +++ b/scripts/bareboxtlv-generator/bareboxtlv-generator.py
> @@ -2,9 +2,15 @@
>
> import argparse
> import struct
> +import sys
>
> import yaml
> -from crcmod.predefined import mkPredefinedCrcFun
> +
> +try:
> + from crcmod.predefined import mkPredefinedCrcFun
> +except ModuleNotFoundError:
> + print("Error: missing crcmod dependency", file=sys.stderr)
> + sys.exit(127)
>
> _crc32_mpeg = mkPredefinedCrcFun("crc-32-mpeg")
>
Could you move this change to a separate patch which is not a fixup?
> diff --git a/test/py/test_tlv.py b/test/py/test_tlv.py
> index 963f3749b33b..79f9f9d01bbb 100644
> --- a/test/py/test_tlv.py
> +++ b/test/py/test_tlv.py
> @@ -2,11 +2,8 @@ import os
> import re
> import subprocess
> from pathlib import Path
> -from crcmod.predefined import mkPredefinedCrcFun
> from .helper import skip_disabled
>
> -_crc32_mpeg = mkPredefinedCrcFun("crc-32-mpeg")
> -
> import pytest
>
>
> @@ -14,6 +11,9 @@ class _TLV_Testdata:
> def generator(self, args, check=True):
> cmd = [os.sys.executable, str(self.generator_py)] + args
> res = subprocess.run(cmd, text=True)
> + if res.returncode == 127:
> + pytest.skip("test skipped due to missing host dependencies")
> +
> if check and res.returncode != 0:
> raise RuntimeError(f"generator failed ({res.returncode}): {res.stdout}\n{res.stderr}")
> return res
And only leave this as fixup to the change on the test case?
The reason it bothers me is that I'd like TLV signature without the
integration tests to be easily backportable.
Regards,
Jonas
--
Pengutronix e.K. | Jonas Rebmann |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-14 15:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-13 12:00 [PATCH] fixup! test: py: add TLV integration tests Ahmad Fatoum
2025-10-14 15:26 ` Jonas Rebmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox