aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2022-09-21 20:29:28 +0800
committerLasse Collin <lasse.collin@tukaani.org>2022-09-29 16:54:39 +0300
commit5e53a6c28b87a0bb9b0cfeaf708cc99ef8e9bc66 (patch)
tree011198a36f9a4a33728f9b8f6578f12a74a3c1d8 /tests
parentliblzma: Fix copying of check type statistics in lzma_index_cat(). (diff)
downloadxz-5e53a6c28b87a0bb9b0cfeaf708cc99ef8e9bc66.tar.xz
Tests: Create a test for the lzma_index_cat bug.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_index.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/tests/test_index.c b/tests/test_index.c
index ce2cfe10..d9e63dd0 100644
--- a/tests/test_index.c
+++ b/tests/test_index.c
@@ -290,7 +290,7 @@ test_many(lzma_index *i)
static void
test_cat(void)
{
- lzma_index *a, *b, *c;
+ lzma_index *a, *b, *c, *d, *e, *f;
lzma_index_iter r;
// Empty Indexes
@@ -411,6 +411,47 @@ test_cat(void)
^ (i == 0));
lzma_index_end(a, NULL);
+
+ // Test for the bug fix 3d5a99ca373a4e86faf671226ca6487febb9eeac.
+ // lzma_index_checks would previously only return the checks
+ // for the last stream that was concatenated to the index.
+ d = create_small();
+ e = create_small();
+ f = create_small();
+
+ lzma_stream_flags crc32_flags = {
+ .backward_size = LZMA_BACKWARD_SIZE_MIN,
+ .check = LZMA_CHECK_CRC32
+ };
+ expect(lzma_index_stream_flags(d, &crc32_flags) == LZMA_OK);
+
+ lzma_stream_flags crc64_flags = {
+ .backward_size = LZMA_BACKWARD_SIZE_MIN,
+ .check = LZMA_CHECK_CRC64
+ };
+ expect(lzma_index_stream_flags(e, &crc64_flags) == LZMA_OK);
+
+ lzma_stream_flags sha256_flags = {
+ .backward_size = LZMA_BACKWARD_SIZE_MIN,
+ .check = LZMA_CHECK_SHA256
+ };
+ expect(lzma_index_stream_flags(f, &sha256_flags) == LZMA_OK);
+
+ expect(lzma_index_checks(d) == (1U << LZMA_CHECK_CRC32));
+ expect(lzma_index_checks(e) == (1U << LZMA_CHECK_CRC64));
+ expect(lzma_index_checks(f) == (1U << LZMA_CHECK_SHA256));
+
+ expect(lzma_index_cat(d, e, NULL) == LZMA_OK);
+ expect(lzma_index_checks(d) == ((1U << LZMA_CHECK_CRC32) |
+ (1U << LZMA_CHECK_CRC64)));
+
+ expect(lzma_index_cat(d, f, NULL) == LZMA_OK);
+ expect(lzma_index_checks(d) == ((1U << LZMA_CHECK_CRC32) |
+ (1U << LZMA_CHECK_CRC64) |
+ (1U << LZMA_CHECK_SHA256)));
+
+ lzma_index_end(d, NULL);
+
}