X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Ftest-compress-benchmark.c;h=c8e5b76c6ce29e234d8a8d2b2e6c7602e6ed9864;hb=fc07d5d3a982e59d984d6be54342a18028faf7be;hp=a346447b4ce92bc9da4eaca28746be33696b6785;hpb=da2e1c71662c348d31f0fc39e42963283c550a28;p=elogind.git diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c index a346447b4..c8e5b76c6 100644 --- a/src/journal/test-compress-benchmark.c +++ b/src/journal/test-compress-benchmark.c @@ -21,9 +21,9 @@ #include "util.h" #include "macro.h" -typedef int (compress_t)(const void *src, uint64_t src_size, void *dst, uint64_t *dst_size); +typedef int (compress_t)(const void *src, uint64_t src_size, void *dst, size_t *dst_size); typedef int (decompress_t)(const void *src, uint64_t src_size, - void **dst, uint64_t *dst_alloc_size, uint64_t* dst_size, uint64_t dst_max); + void **dst, size_t *dst_alloc_size, size_t* dst_size, size_t dst_max); #define MAX_SIZE (1024*1024LU) @@ -32,7 +32,7 @@ static char* make_buf(size_t count) { size_t i; buf = malloc(count); - assert(buf); + assert_se(buf); for (i = 0; i < count; i++) buf[i] = 'a' + i % ('z' - 'a' + 1); @@ -47,39 +47,39 @@ static void test_compress_decompress(const char* label, _cleanup_free_ char *text, *buf; _cleanup_free_ void *buf2 = NULL; - uint64_t buf2_allocated = 0; + size_t buf2_allocated = 0; size_t skipped = 0, compressed = 0, total = 0; text = make_buf(MAX_SIZE); buf = calloc(MAX_SIZE + 1, 1); - assert(text && buf); + assert_se(text && buf); n = now(CLOCK_MONOTONIC); for (size_t i = 1; i <= MAX_SIZE; i += (i < 2048 ? 1 : 217)) { - uint64_t j = 0, k = 0; + size_t j = 0, k = 0; int r; r = compress(text, i, buf, &j); - /* assume compresion must be succesful except for small inputs */ - assert(r == 0 || (i < 2048 && r == -ENOBUFS)); + /* assume compression must be successful except for small inputs */ + assert_se(r == 0 || (i < 2048 && r == -ENOBUFS)); /* check for overwrites */ - assert(buf[i] == 0); + assert_se(buf[i] == 0); if (r != 0) { skipped += i; continue; } - assert(j > 0); + assert_se(j > 0); if (j >= i) - log_error("%s \"compressed\" %zu -> " PRIu64, label, i, j); + log_error("%s \"compressed\" %zu -> %zu", label, i, j); r = decompress(buf, j, &buf2, &buf2_allocated, &k, 0); - assert(r == 0); - assert(buf2_allocated >= k); - assert(k == i); + assert_se(r == 0); + assert_se(buf2_allocated >= k); + assert_se(k == i); - assert(memcmp(text, buf2, i) == 0); + assert_se(memcmp(text, buf2, i) == 0); total += i; compressed += j;