summaryrefslogtreecommitdiff
path: root/test/cmd/unzip.c
AgeCommit message (Collapse)Author
2026-04-22gunzip: Implement chunked decompressionMarek Vasut
The current gzwrite() implementation is limited to 4 GiB compressed input buffer size due to struct z_stream_s { uInt avail_in } member, which is of type unsigned int. Current gzwrite() implementation sets the entire input buffer size as avail_in and performs decompression of the whole compressed input buffer in one round, which limits the size of input buffer to 4 GiB. Rework the decompression loop to use chunked approach, and decompress the input buffer in up to 4 GiB - 1 kiB avail_in chunks, possibly in multiple decompression rounds. This way, the compressed input buffer size is limited by gzwrite() function 'len' parameter type, which is unsigned long. In case of sandbox build, include parsing of 'gzwrite_chunk' environment variable, so the chunked approach can be thoroughly tested with non default chunk size. For non-sandbox builds, the chunk size is 4 GiB - 1 kiB. The gzwrite test case is extended to test various chunk sizes during gzwrite decompression test. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2026-02-18test: cmd: Add test for zip/unzip/gzwrite commandsMarek Vasut
Add simple test for zip/unzip/gzwrite commands. The test works as follows. First, create three buffers with a bit of space between each of them, fill them with random data, then compress data in buffer 1 into buffer 2, decompress data in buffer 2 either directly into buffer 3 or into MMC 1 and then read them back into buffer 3, and finally compare buffer 1 and buffer 3, they have to be identical. The buffers are filled with random data to detect out of bounds writes. Test for various sizes, both small and large and unaligned. The test uses ut_assert_skip_to_line() to skip over gzwrite progress bar. Since the progress bar updates fill up the console record buffer, increase the size of it to compensate. Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>