diff options
author | Colin Walters <walters@verbum.org> | 2017-01-25 09:25:27 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-02-02 16:51:36 +0000 |
commit | 5eea1cdad8a5fa8a96c561248d9dabbc0b848016 (patch) | |
tree | 9fac6f9731dc64ee3c07de5051468d22654277fc /src/libostree/bupsplit.c | |
parent | 95b15afe134cbbcab7f9c331126487889ef3fcb2 (diff) | |
download | ostree-5eea1cdad8a5fa8a96c561248d9dabbc0b848016.tar.gz |
lib: Move the bupsplit selftest into our test framework
We weren't running it before. Also I switched it to use GLib. Preparation for
some oxidation work (having an implementation of bupsplit in Rust).
I exported another function to do the raw rollsum operation which is what this
test suite uses.
Closes: #655
Approved by: jlebon
Diffstat (limited to 'src/libostree/bupsplit.c')
-rw-r--r-- | src/libostree/bupsplit.c | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/src/libostree/bupsplit.c b/src/libostree/bupsplit.c index 067b2e96..79207a65 100644 --- a/src/libostree/bupsplit.c +++ b/src/libostree/bupsplit.c @@ -80,7 +80,8 @@ static uint32_t rollsum_digest(Rollsum *r) } -static uint32_t rollsum_sum(uint8_t *buf, size_t ofs, size_t len) +uint32_t +bupsplit_sum(uint8_t *buf, size_t ofs, size_t len) { size_t count; Rollsum r; @@ -115,38 +116,3 @@ int bupsplit_find_ofs(const unsigned char *buf, int len, int *bits) } return 0; } - - -#ifndef BUP_NO_SELFTEST -#define BUP_SELFTEST_SIZE 100000 - -int bupsplit_selftest() -{ - uint8_t *buf = malloc(BUP_SELFTEST_SIZE); - uint32_t sum1a, sum1b, sum2a, sum2b, sum3a, sum3b; - unsigned count; - - srandom(1); - for (count = 0; count < BUP_SELFTEST_SIZE; count++) - buf[count] = random(); - - sum1a = rollsum_sum(buf, 0, BUP_SELFTEST_SIZE); - sum1b = rollsum_sum(buf, 1, BUP_SELFTEST_SIZE); - sum2a = rollsum_sum(buf, BUP_SELFTEST_SIZE - BUP_WINDOWSIZE*5/2, - BUP_SELFTEST_SIZE - BUP_WINDOWSIZE); - sum2b = rollsum_sum(buf, 0, BUP_SELFTEST_SIZE - BUP_WINDOWSIZE); - sum3a = rollsum_sum(buf, 0, BUP_WINDOWSIZE+3); - sum3b = rollsum_sum(buf, 3, BUP_WINDOWSIZE+3); - - fprintf(stderr, "sum1a = 0x%08x\n", sum1a); - fprintf(stderr, "sum1b = 0x%08x\n", sum1b); - fprintf(stderr, "sum2a = 0x%08x\n", sum2a); - fprintf(stderr, "sum2b = 0x%08x\n", sum2b); - fprintf(stderr, "sum3a = 0x%08x\n", sum3a); - fprintf(stderr, "sum3b = 0x%08x\n", sum3b); - - free(buf); - return sum1a!=sum1b || sum2a!=sum2b || sum3a!=sum3b; -} - -#endif // !BUP_NO_SELFTEST |