diff options
Diffstat (limited to 'xdelta3/xdelta3-test.h')
-rw-r--r-- | xdelta3/xdelta3-test.h | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h index 3d505fc..ccb158b 100644 --- a/xdelta3/xdelta3-test.h +++ b/xdelta3/xdelta3-test.h | |||
@@ -1556,6 +1556,45 @@ test_choose_instruction (xd3_stream *stream, int ignore) | |||
1556 | return 0; | 1556 | return 0; |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | static int | ||
1560 | test_checksum_step (xd3_stream *stream, int ignore) | ||
1561 | { | ||
1562 | const int bufsize = 128; | ||
1563 | uint8_t buf[bufsize]; | ||
1564 | for (int i = 0; i < bufsize; i++) | ||
1565 | { | ||
1566 | buf[i] = mt_random (&static_mtrand) & 0xff; | ||
1567 | } | ||
1568 | |||
1569 | for (usize_t cksize = 4; cksize <= 32; cksize += 3) | ||
1570 | { | ||
1571 | xd3_hash_cfg h1; | ||
1572 | usize_t x; | ||
1573 | int ret; | ||
1574 | |||
1575 | if ((ret = xd3_size_hashtable (stream, XD3_ALLOCSIZE, cksize, &h1)) != 0) | ||
1576 | { | ||
1577 | return ret; | ||
1578 | } | ||
1579 | |||
1580 | x = xd3_large_cksum (&h1, buf, cksize); | ||
1581 | for (usize_t pos = 0; pos <= (bufsize - cksize); pos++) | ||
1582 | { | ||
1583 | usize_t y = xd3_large_cksum (&h1, buf + pos, cksize); | ||
1584 | if (x != y) | ||
1585 | { | ||
1586 | stream->msg = "checksum != incremental checksum"; | ||
1587 | return XD3_INTERNAL; | ||
1588 | } | ||
1589 | x = xd3_large_cksum_update (&h1, x, buf + pos, cksize); | ||
1590 | } | ||
1591 | |||
1592 | xd3_free (stream, h1.powers); | ||
1593 | } | ||
1594 | |||
1595 | return 0; | ||
1596 | } | ||
1597 | |||
1559 | /*********************************************************************** | 1598 | /*********************************************************************** |
1560 | 64BIT STREAMING | 1599 | 64BIT STREAMING |
1561 | ***********************************************************************/ | 1600 | ***********************************************************************/ |
@@ -2839,8 +2878,7 @@ test_in_memory (xd3_stream *stream, int ignore) | |||
2839 | TEST MAIN | 2878 | TEST MAIN |
2840 | ***********************************************************************/ | 2879 | ***********************************************************************/ |
2841 | 2880 | ||
2842 | static int | 2881 | int xd3_selftest (void) |
2843 | xd3_selftest (void) | ||
2844 | { | 2882 | { |
2845 | #define DO_TEST(fn,flags,arg) \ | 2883 | #define DO_TEST(fn,flags,arg) \ |
2846 | do { \ | 2884 | do { \ |
@@ -2867,8 +2905,8 @@ xd3_selftest (void) | |||
2867 | DO_TEST (encode_decode_uint32_t, 0, 0); | 2905 | DO_TEST (encode_decode_uint32_t, 0, 0); |
2868 | DO_TEST (encode_decode_uint64_t, 0, 0); | 2906 | DO_TEST (encode_decode_uint64_t, 0, 0); |
2869 | DO_TEST (usize_t_overflow, 0, 0); | 2907 | DO_TEST (usize_t_overflow, 0, 0); |
2908 | DO_TEST (checksum_step, 0, 0); | ||
2870 | DO_TEST (forward_match, 0, 0); | 2909 | DO_TEST (forward_match, 0, 0); |
2871 | |||
2872 | DO_TEST (address_cache, 0, 0); | 2910 | DO_TEST (address_cache, 0, 0); |
2873 | 2911 | ||
2874 | DO_TEST (string_matching, 0, 0); | 2912 | DO_TEST (string_matching, 0, 0); |