The block numbers do not give us comlete enough coverage, so add a simple checksum that includes all transmitted bytes. Keep block numbers though: they are invaluable when comparing specific damage with a traces of events inside tabled. Signed-off-by: Pete Zaitcev <zaitcev@xxxxxxxxxx> --- test/large-object.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) commit 713da3a60b5763a11ca63593965e31a5b924ca13 Author: Master <zaitcev@xxxxxxxxxxxxxxxxxx> Date: Tue Jan 5 20:51:53 2010 -0700 Add checksums. diff --git a/test/large-object.c b/test/large-object.c index b656333..919bbc4 100644 --- a/test/large-object.c +++ b/test/large-object.c @@ -44,12 +44,14 @@ #define NBLKS2 30000 struct put_ctx { + unsigned int csum; unsigned int blksize; unsigned long off; unsigned long total; }; struct get_ctx { + unsigned int csum; unsigned int blksize; unsigned long off; }; @@ -57,6 +59,22 @@ struct get_ctx { static char bucket[] = "test-large"; static char key[] = "Key of Large Object"; +#define CSUM_INIT 0xFFFFFFFF + +static void incrsum(unsigned int *psum, unsigned char *data, size_t len) +{ + unsigned int sum; + + sum = *psum; + while (len) { + sum ^= *data; + sum = sum << 1 | sum >> 31; + data++; + --len; + } + *psum = sum; +} + static size_t put_cb(void *ptr, size_t membsize, size_t nmemb, void *user_data) { struct put_ctx *ctx = user_data; @@ -84,6 +102,8 @@ static size_t put_cb(void *ptr, size_t membsize, size_t nmemb, void *user_data) if (off == 0) data[0] = num; + incrsum(&ctx->csum, data, rem); + ctx->off += rem; return rem; @@ -131,6 +151,8 @@ static size_t get_cb(void *ptr, size_t membsize, size_t nmemb, void *user_data) OK(membsize == 1); + incrsum(&ctx->csum, ptr, nmemb); + togo = nmemb; while (togo) { len = get_one(ctx, ptr, togo); @@ -144,11 +166,13 @@ static void runtest(struct httpstor_client *httpstor, size_t blklen, int nblks) { off_t total = blklen * nblks; + unsigned int checksum; struct put_ctx putctx; struct get_ctx getctx; bool rcb; memset(&putctx, 0, sizeof(putctx)); + putctx.csum = CSUM_INIT; putctx.blksize = blklen; putctx.total = total; @@ -156,12 +180,17 @@ static void runtest(struct httpstor_client *httpstor, OK(rcb); OK(putctx.off == total); + checksum = putctx.csum; + memset(&getctx, 0, sizeof(getctx)); + getctx.csum = CSUM_INIT; getctx.blksize = blklen; rcb = httpstor_get(httpstor, bucket, key, get_cb, &getctx, false); OK(rcb); OK(getctx.off == total); + + OK(checksum == getctx.csum); } int main(int argc, char *argv[]) -- To unsubscribe from this list: send the line "unsubscribe hail-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html