[PATCH] fixup! test: py: add TLV integration tests

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Oct 13 05:00:30 PDT 2025


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 at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at 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




More information about the barebox mailing list