15 #define MEMLIMIT (LZMA_VLI_C(1) << 20)
18 #define BIG_COUNT 5555
62 expect(lzma_index_total_size(
i) == total_size);
64 expect(lzma_index_total_size(
i) + lzma_index_size(
i)
66 == lzma_index_stream_size(
i));
77 lzma_index_iter_init(&ra,
a);
78 lzma_index_iter_init(&rb,
b);
84 return !(reta ^ retb);
142 lzma_index_end(
a,
NULL);
143 lzma_index_end(
b,
NULL);
144 lzma_index_end(
c,
NULL);
159 lzma_index_end(
i,
NULL);
169 lzma_index_end(
d,
NULL);
177 lzma_index_iter_init(&
r,
i);
180 for (
size_t j = 0; j < 2; ++j) {
190 total_size +=
r.block.total_size;
193 expect(
r.block.compressed_file_offset
195 expect(
r.block.uncompressed_file_offset
196 == uncompressed_offset);
199 uncompressed_offset +=
r.block.uncompressed_size;
202 expect(lzma_index_total_size(
i) == total_size);
206 lzma_index_iter_rewind(&
r);
214 const size_t alloc_size = 128 * 1024;
233 lzma_index_end(
d,
NULL);
240 lzma_index_iter_init(&
r,
i);
242 expect(lzma_index_hash_append(
h,
r.block.unpadded_size,
243 r.block.uncompressed_size) ==
LZMA_OK);
251 lzma_index_hash_end(
h,
NULL);
275 lzma_index_end(
d,
NULL);
300 expect(lzma_index_block_count(
a) == 0);
304 lzma_index_iter_init(&
r,
a);
309 expect(lzma_index_block_count(
a) == 0);
318 expect(lzma_index_block_count(
b) == 0);
325 expect(lzma_index_block_count(
a) == 0);
331 lzma_index_iter_rewind(&
r);
333 lzma_index_end(
a,
NULL);
337 lzma_vli stream_size = lzma_index_stream_size(
a);
338 lzma_index_iter_init(&
r,
a);
346 expect(lzma_index_file_size(
a) == stream_size * 2 + 4);
347 expect(lzma_index_stream_size(
a) > stream_size);
348 expect(lzma_index_stream_size(
a) < stream_size * 2);
353 lzma_index_iter_rewind(&
r);
364 expect(lzma_index_file_size(
a) == stream_size * 4 + 4 + 8 + 12);
371 lzma_index_iter_rewind(&
r);
376 lzma_index_end(
a,
NULL);
383 lzma_index_iter_init(&
r,
a);
388 lzma_index_end(
a,
NULL);
392 stream_size = lzma_index_stream_size(
a);
396 expect(lzma_index_file_size(
a) == stream_size * 2 + 4);
397 expect(lzma_index_stream_size(
a) > stream_size);
398 expect(lzma_index_stream_size(
a) < stream_size * 2);
406 expect(lzma_index_file_size(
a) == stream_size * 4 + 4 + 8 + 12);
408 lzma_index_iter_init(&
r,
a);
413 lzma_index_end(
a,
NULL);
423 lzma_index_iter_init(&
r,
i);
426 expect(lzma_index_iter_locate(&
r, 0));
427 expect(lzma_index_iter_locate(&
r, 555));
432 expect(lzma_index_iter_locate(&
r, 0));
436 expect(!lzma_index_iter_locate(&
r, 0));
437 expect(
r.block.total_size == 32);
438 expect(
r.block.uncompressed_size == 5);
439 expect(
r.block.compressed_file_offset
441 expect(
r.block.uncompressed_file_offset == 0);
444 expect(lzma_index_iter_locate(&
r, 5));
449 expect(!lzma_index_iter_locate(&
r, 0));
450 expect(
r.block.total_size == 32);
451 expect(
r.block.uncompressed_size == 5);
452 expect(
r.block.compressed_file_offset
454 expect(
r.block.uncompressed_file_offset == 0);
457 expect(
r.block.total_size == 40);
458 expect(
r.block.uncompressed_size == 11);
459 expect(
r.block.compressed_file_offset
461 expect(
r.block.uncompressed_file_offset == 5);
463 expect(!lzma_index_iter_locate(&
r, 2));
464 expect(
r.block.total_size == 32);
465 expect(
r.block.uncompressed_size == 5);
466 expect(
r.block.compressed_file_offset
468 expect(
r.block.uncompressed_file_offset == 0);
470 expect(!lzma_index_iter_locate(&
r, 5));
471 expect(
r.block.total_size == 40);
472 expect(
r.block.uncompressed_size == 11);
473 expect(
r.block.compressed_file_offset
475 expect(
r.block.uncompressed_file_offset == 5);
477 expect(!lzma_index_iter_locate(&
r, 5 + 11 - 1));
478 expect(
r.block.total_size == 40);
479 expect(
r.block.uncompressed_size == 11);
480 expect(
r.block.compressed_file_offset
482 expect(
r.block.uncompressed_file_offset == 5);
484 expect(lzma_index_iter_locate(&
r, 5 + 11));
485 expect(lzma_index_iter_locate(&
r, 5 + 15));
488 lzma_index_end(
i,
NULL);
489 i = lzma_index_init(
NULL);
491 lzma_index_iter_init(&
r,
i);
493 for (
size_t n = 4;
n <= 4 * 5555;
n += 4)
496 expect(lzma_index_block_count(
i) == 5555);
499 expect(!lzma_index_iter_locate(&
r, 0));
500 expect(
r.block.total_size == 4 + 8);
501 expect(
r.block.uncompressed_size == 4);
503 expect(
r.block.uncompressed_file_offset == 0);
505 expect(!lzma_index_iter_locate(&
r, 3));
506 expect(
r.block.total_size == 4 + 8);
507 expect(
r.block.uncompressed_size == 4);
509 expect(
r.block.uncompressed_file_offset == 0);
512 expect(!lzma_index_iter_locate(&
r, 4));
513 expect(
r.block.total_size == 2 * 4 + 8);
514 expect(
r.block.uncompressed_size == 2 * 4);
515 expect(
r.block.compressed_file_offset
517 expect(
r.block.uncompressed_file_offset == 4);
520 expect(!lzma_index_iter_locate(
521 &
r, lzma_index_uncompressed_size(
i) - 1));
522 expect(
r.block.total_size == 4 * 5555 + 8);
523 expect(
r.block.uncompressed_size == 4 * 5555);
524 expect(
r.block.compressed_file_offset == lzma_index_total_size(
i)
526 expect(
r.block.uncompressed_file_offset
527 == lzma_index_uncompressed_size(
i) - 4 * 5555);
531 const size_t group_multiple = 256 * 4;
532 const size_t radius = 8;
533 const size_t start = group_multiple - radius;
542 while (
n <
start + 2 * radius) {
543 expect(!lzma_index_iter_locate(&
r, ubase +
n * 4));
545 expect(
r.block.compressed_file_offset == tbase +
n * 4 + 8
547 expect(
r.block.uncompressed_file_offset == ubase +
n * 4);
553 expect(
r.block.total_size ==
n * 4 + 8);
554 expect(
r.block.uncompressed_size ==
n * 4);
559 expect(!lzma_index_iter_locate(&
r, ubase + (
n - 1) * 4));
561 expect(
r.block.total_size ==
n * 4 + 8);
562 expect(
r.block.uncompressed_size ==
n * 4);
568 expect(
r.block.compressed_file_offset == tbase +
n * 4 + 8
570 expect(
r.block.uncompressed_file_offset == ubase +
n * 4);
574 lzma_index_end(
i,
NULL);
575 i = lzma_index_init(
NULL);
577 lzma_index_iter_init(&
r,
i);
578 for (
n = 0;
n < group_multiple; ++
n)
581 expect(!lzma_index_iter_locate(&
r, 0));
582 expect(
r.block.total_size == 16);
583 expect(
r.block.uncompressed_size == 1);
584 expect(
r.block.compressed_file_offset
586 expect(
r.block.uncompressed_file_offset == 0);
588 lzma_index_end(
i,
NULL);
595 const size_t alloc_size = 128 * 1024;
602 lzma_index_end(
i,
NULL);
609 lzma_index_end(
i,
NULL);
639 static unsigned count = 0;
658 lzma_index_end(
i,
NULL);
662 lzma_index_end(
i,
NULL);
666 lzma_index_end(
i,
NULL);
679 lzma_index_end(
i,
NULL);
686 lzma_index_end(
i,
NULL);
@ LZMA_INDEX_ITER_BLOCK
Get the next Block.
@ LZMA_INDEX_ITER_ANY
Get the next Block or Stream.
static lzma_vli index_size(lzma_vli count, lzma_vli index_list_size)
Calculate the size of the Index field including Index Padding.
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
RZ_API void Ht_() free(HtName_(Ht) *ht)
void * malloc(size_t size)
#define expect(expr, value)
#define LZMA_STREAM_HEADER_SIZE
Size of Stream Header and Stream Footer.
Custom functions for memory handling.
Iterator to get information about Blocks and Streams.
struct lzma_index_iter::@635 stream
lzma_vli uncompressed_stream_offset
Uncompressed start offset of this Block.
lzma_vli number
Stream number in the lzma_index.
lzma_vli compressed_file_offset
Compressed start offset of this Block.
lzma_vli uncompressed_file_offset
Uncompressed start offset of this Block.
lzma_vli number_in_stream
Block number in this Stream.
lzma_vli compressed_offset
Compressed start offset of this Stream.
lzma_vli padding
Size of Stream Padding after this Stream.
lzma_vli compressed_stream_offset
Compressed start offset of this Block.
lzma_vli compressed_size
Compressed size of this Stream.
struct lzma_index_iter::@636 block
lzma_vli unpadded_size
Unpadded size of this Block.
lzma_vli uncompressed_size
Uncompressed size of this Stream.
lzma_vli block_count
Number of Blocks in the Stream.
lzma_vli uncompressed_offset
Uncompressed start offset of this Stream.
lzma_vli number_in_file
Block number in the file.
lzma_vli total_size
Total compressed size.
Passing data to and from liblzma.
static uint32_t stream_offset(Stream *self)
uint64_t uncompressed_size
static void test_cat(void)
static void test_equal(void)
static void test_overflow(void)
static lzma_index * create_empty(void)
static lzma_index * create_small(void)
static lzma_index * create_big(void)
static void * my_alloc(void *opaque, size_t a, size_t b)
static bool is_equal(const lzma_index *a, const lzma_index *b)
static void test_read(lzma_index *i)
static void test_many(lzma_index *i)
static void test_copy(const lzma_index *i)
static void test_code(lzma_index *i)
static void test_locate(void)
static const lzma_allocator my_allocator
static void test_corrupt(void)
Common definitions for test applications.
static bool coder_loop(lzma_stream *strm, uint8_t *in, size_t in_size, uint8_t *out, size_t out_size, lzma_ret expected_ret, lzma_action finishing_action)
static bool decoder_loop_ret(lzma_stream *strm, uint8_t *in, size_t in_size, lzma_ret expected_ret)
static bool decoder_loop(lzma_stream *strm, uint8_t *in, size_t in_size)
uint64_t lzma_vli
Variable-length integer type.
#define LZMA_VLI_C(n)
VLI constant suffix.
#define LZMA_VLI_MAX
Maximum supported value of a variable-length integer.
@ LZMA_PROG_ERROR
Programming error.
@ LZMA_DATA_ERROR
Data is corrupt.
@ LZMA_STREAM_END
End of stream was reached.
@ LZMA_BUF_ERROR
No progress is possible.
@ LZMA_OK
Operation completed successfully.
@ LZMA_RUN
Continue coding.
#define LZMA_STREAM_INIT
Initialization for lzma_stream.