[PATCH v2 04/10] binman: Add compression tests
Stefan Herbrechtsmeier
stefan.herbrechtsmeier-oss at weidmueller.com
Mon Aug 8 12:51:19 CEST 2022
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>
Add common test functions to test all supported compressions.
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>
---
Instead of the for loop it is possible to use Parameterized [1] testing.
[1] https://github.com/wolever/parameterized
Changes in v2:
- Added
tools/binman/ftest.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 96c15cff77..c9b67c48d6 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5248,6 +5248,30 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
comp_util.decompress(b'1234', 'invalid')
self.assertIn("Unknown algorithm 'invalid'", str(e.exception))
+ def testCompressions(self):
+ """Test compression algorithms"""
+ for algo in comp_util.COMPRESSIONS:
+ data = comp_util.compress(COMPRESS_DATA, algo)
+ self.assertNotEqual(COMPRESS_DATA, data)
+ orig = comp_util.decompress(data, algo)
+ self.assertEquals(COMPRESS_DATA, orig)
+
+ def testVersions(self):
+ """Test tool version of compression algorithms"""
+ for algo in comp_util.COMPRESSIONS:
+ tool = comp_util._get_tool(algo)
+ version = tool.version()
+ print('%s - %s' % (algo, version))
+ self.assertRegex(version, '^v?[0-9]+[0-9.]*')
+
+ def testPadding(self):
+ """Test padding of compression algorithms"""
+ for algo in comp_util.COMPRESSIONS:
+ data = comp_util.compress(COMPRESS_DATA, algo)
+ data = data + bytes([0]) * 64
+ orig = comp_util.decompress(data, algo)
+ self.assertEquals(COMPRESS_DATA, orig)
+
def testBintoolDocs(self):
"""Test for creation of bintool documentation"""
with test_util.capture_sys_output() as (stdout, stderr):
--
2.30.2
More information about the U-Boot
mailing list