]> git.ozlabs.org Git - ccan/blobdiff - ccan/crcsync/test/run-crash.c
Convert to 64 bit crcs: change semantics of crcbits field to be *upper* not *lower...
[ccan] / ccan / crcsync / test / run-crash.c
index c047cce28c0d7d8f26f0d0a5874def9a8b06a2e4..c2561e5d69134862aca8bd651186d18a9cd5858a 100644 (file)
 
 typedef struct {
        int block_count;
-       unsigned int *crcs;
+       uint64_t *crcs;
 } crc_info_t;
 
 static void crcblocks(crc_info_t *crc_info, char *data, int datalen, int blocksize)
 {
        crc_info->block_count = (datalen+blocksize-1)/blocksize;
-       crc_info->crcs = malloc(sizeof(unsigned int)*(crc_info->block_count + 1));
-       crc_of_blocks(data, datalen, blocksize, 30, crc_info->crcs);
+       crc_info->crcs = malloc(sizeof(uint64_t)*(crc_info->block_count + 1));
+       crc_of_blocks(data, datalen, blocksize, 60, crc_info->crcs);
 }
 
 #define BLOCKSIZE 5
@@ -39,26 +39,30 @@ int main(int argc, char *argv[])
                "pqr-a-very-long-test-that-differs-between-two-invokations-of-the-same-page-st"
                /* MATCH */
                "uvwxy" "z ABC" "DEFGH" "IJKLM" "NOPQR" "STUVW" "XYZ 0" "12345"
+               "6789"
                /* NO MATCH */
-               "6789ab";
+               "ab";
 
        int expected[] = { 4,
                           -2, -3,
                           77,
                           -5, -6, -7, -8, -9, -10, -11, -12,
-                          6 };
+                          -13,
+                          2 };
        crc_info_t crc_info1;
        struct crc_context *crcctx;
        long result;
        size_t ndigested;
        size_t offset = 0;
        size_t len2 = strlen(data2);
+       size_t tailsize = strlen(data1) % BLOCKSIZE;
        int expected_i = 0;
 
        plan_tests(ARRAY_SIZE(expected) + 2);
        crcblocks(&crc_info1, data1, strlen(data1), BLOCKSIZE);
 
-       crcctx = crc_context_new(BLOCKSIZE, 30, crc_info1.crcs, crc_info1.block_count);
+       crcctx = crc_context_new(BLOCKSIZE, 60, crc_info1.crcs, crc_info1.block_count,
+                                tailsize);
        while ( offset < len2)
        {
                ndigested = crc_read_block(crcctx, &result, data2+offset, len2 - offset);