forked from vitalif/vitastor
Add crc32c test utility
parent
a276a1f737
commit
5953942042
|
@ -263,6 +263,14 @@ target_link_libraries(test_cas
|
||||||
vitastor_client
|
vitastor_client
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# test_crc32
|
||||||
|
add_executable(test_crc32
|
||||||
|
test_crc32.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(test_crc32
|
||||||
|
vitastor_blk
|
||||||
|
)
|
||||||
|
|
||||||
# test_cluster_client
|
# test_cluster_client
|
||||||
add_executable(test_cluster_client
|
add_executable(test_cluster_client
|
||||||
test_cluster_client.cpp
|
test_cluster_client.cpp
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright (c) Vitaliy Filippov, 2019+
|
||||||
|
// License: VNPL-1.1 (see README.md for details)
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "malloc_or_die.h"
|
||||||
|
#include "errno.h"
|
||||||
|
#include "crc32c.h"
|
||||||
|
|
||||||
|
int main(int narg, char *args[])
|
||||||
|
{
|
||||||
|
int bufsize = 65536;
|
||||||
|
uint8_t *buf = (uint8_t*)malloc_or_die(bufsize);
|
||||||
|
uint32_t csum = 0;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int r = read(0, buf, bufsize);
|
||||||
|
if (r <= 0 && errno != EAGAIN && errno != EINTR)
|
||||||
|
break;
|
||||||
|
csum = crc32c(csum, buf, r);
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
|
printf("%08x\n", csum);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue