Repository navigation
Conversation
isal_inflate decompresses up to about 64 KiB ahead into its own buffer, so it read the 100 to 300 byte inputs of these tests in full, and the input buffer was never used. Use 512 KiB of random data and multiply the offsets by 1,000.
rhpvorderman
requested changes
Oct 28, 2026
rhpvorderman
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Just a minor naming nitpick.
Comment on lines
+80
to
+81
| RANDOM_TEXT = random.Random(0).randbytes(512 * 1024) | ||
| RANDOM_DATA = igzip_lib.compress(RANDOM_TEXT) |
Collaborator
There was a problem hiding this comment.
This is a bit unfortunate naming of the variables. This should be RANDOM_DATA as it is not text and COMPRESSED_RANDOM_DATA respectively.
The uncompressed data is random bytes, not text, so RANDOM_TEXT becomes RANDOM_DATA and the compressed data becomes COMPRESSED_RANDOM_DATA.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_decompressor_inputbuf_1,_2, and_3come from CPython'stest_bz2. They expect part of a 100 to 300 byte input to be left over in the input buffer ofIgzipDecompressor. Butisal_inflatedecompresses up to about 64 KiB ahead into a buffer of its own, so it reads these inputs in full. With gcov, the input buffer code indecompress()inigzip_libmodule.cruns in none of the three tests.This PR uses 512 KiB of random data, which needs about as much input as output, and multiplies the offsets by 1,000. In the first test, the second call asks for 80,000 bytes instead of 2, because
isal_inflatefirst returns the data in its own buffer and reads more input only after that. With gcov, the tests now do what their comments say: the first moves the contents of the input buffer to its start withmemmove, the second appends to the buffer without moving or resizing it, and the third resizes it withPyMem_Realloc.To test it, I made two changes to
decompress(). Without thememmove, the first test fails. When the offset is dropped afterPyMem_Realloc, the second test fails. All tests intests/test_igzip_lib.pyondeveloppass with both changes. With an AddressSanitizer build ofigzip_lib, the new tests pass. Together, the three tests take about 0.2 s.This PR changes only tests, so it has no CHANGELOG entry.
Checklist