diff options
Diffstat (limited to 'xdelta3/xdelta3-test.h')
-rw-r--r-- | xdelta3/xdelta3-test.h | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h index fe62a4b..a2ba64f 100644 --- a/xdelta3/xdelta3-test.h +++ b/xdelta3/xdelta3-test.h | |||
@@ -118,7 +118,7 @@ mt_exp_rand (uint32_t mean, uint32_t max_value) | |||
118 | 118 | ||
119 | #define MSG_IS(x) (stream->msg != NULL && strcmp ((x), stream->msg) == 0) | 119 | #define MSG_IS(x) (stream->msg != NULL && strcmp ((x), stream->msg) == 0) |
120 | 120 | ||
121 | static const usize_t TWO_MEGS_AND_DELTA = (2 << 20) + (1 << 10); | 121 | static const usize_t TWO_MEGS_AND_DELTA = (3 << 20); |
122 | static const usize_t ADDR_CACHE_ROUNDS = 10000; | 122 | static const usize_t ADDR_CACHE_ROUNDS = 10000; |
123 | 123 | ||
124 | static const usize_t TEST_FILE_MEAN = 16384; | 124 | static const usize_t TEST_FILE_MEAN = 16384; |
@@ -1590,9 +1590,12 @@ test_streaming (xd3_stream *in_stream, uint8_t *encbuf, uint8_t *decbuf, uint8_t | |||
1590 | xd3_stream estream, dstream; | 1590 | xd3_stream estream, dstream; |
1591 | int ret; | 1591 | int ret; |
1592 | usize_t i, delsize, decsize; | 1592 | usize_t i, delsize, decsize; |
1593 | xd3_config cfg; | ||
1594 | xd3_init_config (& cfg, in_stream->flags); | ||
1595 | cfg.flags |= XD3_COMPLEVEL_6; | ||
1593 | 1596 | ||
1594 | if ((ret = xd3_config_stream (& estream, NULL)) || | 1597 | if ((ret = xd3_config_stream (& estream, & cfg)) || |
1595 | (ret = xd3_config_stream (& dstream, NULL))) | 1598 | (ret = xd3_config_stream (& dstream, & cfg))) |
1596 | { | 1599 | { |
1597 | goto fail; | 1600 | goto fail; |
1598 | } | 1601 | } |
@@ -1605,7 +1608,7 @@ test_streaming (xd3_stream *in_stream, uint8_t *encbuf, uint8_t *decbuf, uint8_t | |||
1605 | 1608 | ||
1606 | if ((ret = xd3_process_stream (1, & estream, xd3_encode_input, 0, | 1609 | if ((ret = xd3_process_stream (1, & estream, xd3_encode_input, 0, |
1607 | encbuf, 1 << 20, | 1610 | encbuf, 1 << 20, |
1608 | delbuf, & delsize, 1 << 10))) | 1611 | delbuf, & delsize, 1 << 20))) |
1609 | { | 1612 | { |
1610 | in_stream->msg = estream.msg; | 1613 | in_stream->msg = estream.msg; |
1611 | goto fail; | 1614 | goto fail; |
@@ -1645,11 +1648,21 @@ static int | |||
1645 | test_compressed_stream_overflow (xd3_stream *stream, int ignore) | 1648 | test_compressed_stream_overflow (xd3_stream *stream, int ignore) |
1646 | { | 1649 | { |
1647 | int ret; | 1650 | int ret; |
1651 | int i; | ||
1648 | uint8_t *buf; | 1652 | uint8_t *buf; |
1649 | 1653 | ||
1650 | if ((buf = (uint8_t*) malloc (TWO_MEGS_AND_DELTA)) == NULL) { return ENOMEM; } | 1654 | if ((buf = (uint8_t*) malloc (TWO_MEGS_AND_DELTA)) == NULL) { return ENOMEM; } |
1651 | 1655 | ||
1652 | memset (buf, 0, TWO_MEGS_AND_DELTA); | 1656 | memset (buf, 0, TWO_MEGS_AND_DELTA); |
1657 | for (i = 0; i < (2 << 20); i += 256) | ||
1658 | { | ||
1659 | int j; | ||
1660 | int off = mt_random(& static_mtrand) % 10; | ||
1661 | for (j = 0; j < 256; j++) | ||
1662 | { | ||
1663 | buf[i + j] = j + off; | ||
1664 | } | ||
1665 | } | ||
1653 | 1666 | ||
1654 | /* Test overflow of a 32-bit file offset. */ | 1667 | /* Test overflow of a 32-bit file offset. */ |
1655 | if (SIZEOF_XOFF_T == 4) | 1668 | if (SIZEOF_XOFF_T == 4) |
@@ -1670,8 +1683,14 @@ test_compressed_stream_overflow (xd3_stream *stream, int ignore) | |||
1670 | } | 1683 | } |
1671 | 1684 | ||
1672 | /* Test transfer of exactly 32bits worth of data. */ | 1685 | /* Test transfer of exactly 32bits worth of data. */ |
1673 | if ((ret = test_streaming (stream, buf, buf + (1 << 20), buf + (2 << 20), 1 << 12))) { goto fail; } | 1686 | if ((ret = test_streaming (stream, |
1674 | 1687 | buf, | |
1688 | buf + (1 << 20), | ||
1689 | buf + (2 << 20), | ||
1690 | 1 << 12))) | ||
1691 | { | ||
1692 | goto fail; | ||
1693 | } | ||
1675 | fail: | 1694 | fail: |
1676 | free (buf); | 1695 | free (buf); |
1677 | return ret; | 1696 | return ret; |
@@ -2816,7 +2835,7 @@ xd3_selftest (void) | |||
2816 | DO_TEST (decompress_single_bit_error, 0, 3); | 2835 | DO_TEST (decompress_single_bit_error, 0, 3); |
2817 | DO_TEST (decompress_single_bit_error, XD3_ADLER32, 3); | 2836 | DO_TEST (decompress_single_bit_error, XD3_ADLER32, 3); |
2818 | 2837 | ||
2819 | IF_LZMA (DO_TEST (decompress_single_bit_error, XD3_SEC_LZMA, 3)); | 2838 | IF_LZMA (DO_TEST (decompress_single_bit_error, XD3_SEC_LZMA, 54)); |
2820 | IF_FGK (DO_TEST (decompress_single_bit_error, XD3_SEC_FGK, 3)); | 2839 | IF_FGK (DO_TEST (decompress_single_bit_error, XD3_SEC_FGK, 3)); |
2821 | IF_DJW (DO_TEST (decompress_single_bit_error, XD3_SEC_DJW, 8)); | 2840 | IF_DJW (DO_TEST (decompress_single_bit_error, XD3_SEC_DJW, 8)); |
2822 | 2841 | ||
@@ -2844,6 +2863,7 @@ xd3_selftest (void) | |||
2844 | IF_FGK (DO_TEST (secondary_fgk, 0, 1)); | 2863 | IF_FGK (DO_TEST (secondary_fgk, 0, 1)); |
2845 | 2864 | ||
2846 | DO_TEST (compressed_stream_overflow, 0, 0); | 2865 | DO_TEST (compressed_stream_overflow, 0, 0); |
2866 | IF_LZMA (DO_TEST (compressed_stream_overflow, XD3_SEC_LZMA, 0)); | ||
2847 | 2867 | ||
2848 | failure: | 2868 | failure: |
2849 | test_cleanup (); | 2869 | test_cleanup (); |