From: Aristo Chen <aristo.chen@canonical.com>
To: u-boot@lists.u-boot-project.org
Cc: sjg@chromium.org, nora.schiffer@ew.tq-group.com,
Aristo Chen <aristo.chen@canonical.com>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 6/8] test: fit: cover the kernel_noload lz4 header-size path
Date: Tue, 18 Aug 2026 13:23:20 +0000 [thread overview]
Message-ID: <20260818132332.324173-7-aristo.chen@canonical.com> (raw)
In-Reply-To: <20260818132332.324173-1-aristo.chen@canonical.com>
Add test_fit_kernel_noload_decomp_lz4_hdr_sized: a 6 MiB payload
whose lz4 compression ratio is past the 8x heuristic decompresses
cleanly because Content_Size is consulted. The tool must be invoked
with --content-size so the frame's FLG bit is set. The test is
guarded by @pytest.mark.requiredtool('lz4') so it skips on hosts
that do not ship the lz4 command.
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
---
test/py/tests/test_fit.py | 47 +++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py
index f59010c8c35..42edddb0600 100755
--- a/test/py/tests/test_fit.py
+++ b/test/py/tests/test_fit.py
@@ -611,6 +611,53 @@ class TestFitImage:
'bootm rejected a well-compressed kernel_noload image whose '
'ISIZE trailer records the real uncompressed size: %s' % text)
+ @pytest.mark.buildconfigspec('lz4')
+ @pytest.mark.requiredtool('lz4')
+ def test_fit_kernel_noload_decomp_lz4_hdr_sized(self, ubman, fsetup):
+ """A well-compressed lz4 kernel_noload image fits when the frame
+ header carries the content size.
+
+ Same as test_fit_kernel_noload_decomp_gzip_hdr_sized but for lz4:
+ the tool must be invoked with --content-size so the frame's FLG
+ bit is set and bootm can read the size instead of falling back to
+ the 8x heuristic.
+ """
+ sz_1m = 1 << 20
+ bootm_len = int(ubman.config.buildconfig['config_sys_bootm_len'], 0)
+
+ decomp_size = 6 * sz_1m
+ assert decomp_size <= bootm_len, (
+ 'Test setup error: decomp_size (%#x) must be <= '
+ 'CONFIG_SYS_BOOTM_LEN (%#x)' % (decomp_size, bootm_len))
+ kernel = fit_util.make_fname(ubman, 'test-noload-kernel-lz4.bin')
+ with open(kernel, 'wb') as fd:
+ fd.write(b'\0' * decomp_size)
+ kernel_lz4 = kernel + '.lz4'
+ utils.run_and_log(
+ ubman, ['lz4', '--content-size', '-f', kernel, kernel_lz4])
+
+ image_len = self.filesize(kernel_lz4)
+ heuristic_bound = (image_len * 8 + sz_1m - 1) // sz_1m * sz_1m
+ assert heuristic_bound < decomp_size, (
+ 'Test setup error: 8x heuristic bound (%#x) must be < uncompressed '
+ 'size (%#x); if this fires, lz4 got less effective and the test '
+ 'needs a bigger payload' % (heuristic_bound, decomp_size))
+
+ fit = fit_util.make_fit(ubman, fsetup['mkimage'], NOLOAD_ITS,
+ {'kernel': kernel_lz4, 'compression': 'lz4'},
+ basename='test-noload-lz4-hdrsized.fit')
+ fit_addr = fsetup['fit_addr']
+
+ output = ubman.run_command_list([
+ 'host load hostfs 0 %x %s' % (fit_addr, fit),
+ 'bootm start %x' % fit_addr,
+ 'bootm loados',
+ ])
+ text = '\n'.join(output)
+ assert 'Image too large' not in text, (
+ 'bootm rejected a well-compressed lz4 kernel_noload image whose '
+ 'frame header records the real content size: %s' % text)
+
@pytest.mark.buildconfigspec('zstd')
@pytest.mark.requiredtool('zstd')
def test_fit_kernel_noload_decomp_zstd_hdr_sized(self, ubman, fsetup):
--
2.43.0
next prev parent reply other threads:[~2026-08-18 13:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 4:23 [PATCH 0/3] bootm: size the noload buffer from the compressor header Aristo Chen via U-Boot
2026-08-09 4:23 ` [PATCH 1/3] bootm: size the noload decompression " Aristo Chen via U-Boot
2026-08-09 15:27 ` Tom Rini
2026-08-10 2:32 ` Aristo Chen via U-Boot
2026-08-10 16:37 ` Tom Rini
2026-08-12 7:45 ` Nora Schiffer
2026-08-12 15:57 ` Tom Rini
2026-08-15 18:33 ` Simon Glass
2026-08-17 16:01 ` Aristo Chen via U-Boot
2026-08-17 19:24 ` Tom Rini
2026-08-09 4:23 ` [PATCH 2/3] test: fit: cover the kernel_noload header-size and lying-header paths Aristo Chen via U-Boot
2026-08-09 4:23 ` [PATCH 3/3] test: lib: cover image_decomp_get_uncompressed_size() for lzma streams Aristo Chen via U-Boot
2026-08-18 13:23 ` [PATCH v2 0/8] bootm: size the noload buffer from the compressor header Aristo Chen
2026-08-18 13:23 ` [PATCH v2 1/8] bootm: size the noload gzip decompression buffer from ISIZE Aristo Chen
2026-08-18 13:23 ` [PATCH v2 2/8] test: fit: cover the kernel_noload gzip header-size and lying-header paths Aristo Chen
2026-08-18 13:23 ` [PATCH v2 3/8] bootm: size the noload zstd decompression buffer from Frame_Content_Size Aristo Chen
2026-08-18 13:23 ` [PATCH v2 4/8] test: fit: cover the kernel_noload zstd header-size path Aristo Chen
2026-08-18 13:23 ` [PATCH v2 5/8] bootm: size the noload lz4 decompression buffer from Content_Size Aristo Chen
2026-08-18 13:23 ` Aristo Chen [this message]
2026-08-18 13:23 ` [PATCH v2 7/8] bootm: size the noload lzma decompression buffer from the header Aristo Chen
2026-08-18 13:23 ` [PATCH v2 8/8] test: fit: cover the kernel_noload lzma header-size and unknown-size paths Aristo Chen
2026-08-18 22:10 ` [PATCH v2 0/8] bootm: size the noload buffer from the compressor header Tom Rini
2026-08-19 14:53 ` Aristo Chen
2026-08-21 18:55 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260818132332.324173-7-aristo.chen@canonical.com \
--to=aristo.chen@canonical.com \
--cc=nora.schiffer@ew.tq-group.com \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.