algsig: Move jerasure backend dlopen up a level
.. also check for errors Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
This commit is contained in:
@@ -28,7 +28,7 @@ include_HEADERS = \
|
||||
include/xor_codes/xor_code.h
|
||||
|
||||
test: check
|
||||
# @./test/alg_sig_test
|
||||
@./test/alg_sig_test
|
||||
@./test/test_xor_hd_code
|
||||
@./test/liberasurecode_test
|
||||
|
||||
@@ -37,9 +37,9 @@ VALGRIND_EXEC_COMMAND = $(LIBTOOL_COMMAND) valgrind --tool=memcheck \
|
||||
--malloc-fill=A5 --free-fill=DE --fullpath-after=.
|
||||
|
||||
valgrind-test: check
|
||||
@$(VALGRIND_EXEC_COMMAND) ./test/alg_sig_test
|
||||
@$(VALGRIND_EXEC_COMMAND) ./test/liberasurecode_test
|
||||
@$(VALGRIND_EXEC_COMMAND) ./test/test_xor_hd_code
|
||||
# @$(VALGRIND_EXEC_COMMAND) ./test/alg_sig_test
|
||||
|
||||
CLEANFILES = cscope.in.out cscope.out cscope.po.out
|
||||
|
||||
|
||||
@@ -21,21 +21,12 @@
|
||||
/* Define to 1 if you have the `free' function. */
|
||||
#undef HAVE_FREE
|
||||
|
||||
/* Define to 1 if you have the <galois.h> header file. */
|
||||
#undef HAVE_GALOIS_H
|
||||
|
||||
/* Define to 1 if you have the <gf_complete.h> header file. */
|
||||
#undef HAVE_GF_COMPLETE_H
|
||||
|
||||
/* Define to 1 if you have the <iconv.h> header file. */
|
||||
#undef HAVE_ICONV_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* "Defined if gf-complete is installed" */
|
||||
#undef HAVE_LIBGF_COMPLETE
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <alg_sig.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -45,7 +46,7 @@ int load_gf_functions(void *sohandle, struct jerasure_mult_routines *routines)
|
||||
}
|
||||
|
||||
static
|
||||
alg_sig_t *init_alg_sig_w8(int sig_len)
|
||||
alg_sig_t *init_alg_sig_w8(void *jerasure_sohandle, int sig_len)
|
||||
{
|
||||
alg_sig_t *alg_sig_handle;
|
||||
int num_gf_lr_table_syms;
|
||||
@@ -55,12 +56,6 @@ alg_sig_t *init_alg_sig_w8(int sig_len)
|
||||
int num_components = sig_len / w;
|
||||
struct jerasure_mult_routines g_jerasure_mult_routines;
|
||||
|
||||
void *jerasure_sohandle = get_jerasure_sohandle();
|
||||
|
||||
if (NULL == jerasure_sohandle) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
alg_sig_handle = (alg_sig_t *)malloc(sizeof(alg_sig_t));
|
||||
if (NULL == alg_sig_handle) {
|
||||
return NULL;
|
||||
@@ -109,7 +104,7 @@ alg_sig_t *init_alg_sig_w8(int sig_len)
|
||||
}
|
||||
|
||||
static
|
||||
alg_sig_t *init_alg_sig_w16(int sig_len)
|
||||
alg_sig_t *init_alg_sig_w16(void *jerasure_sohandle, int sig_len)
|
||||
{
|
||||
alg_sig_t *alg_sig_handle;
|
||||
int num_gf_lr_table_syms;
|
||||
@@ -117,14 +112,13 @@ alg_sig_t *init_alg_sig_w16(int sig_len)
|
||||
int w = 16;
|
||||
int alpha = 2, beta = 4, gamma = 8;
|
||||
int num_components = sig_len / w;
|
||||
|
||||
void *jerasure_sohandle = get_jerasure_sohandle();
|
||||
if (jerasure_sohandle == NULL) {
|
||||
return NULL;
|
||||
|
||||
if (NULL == jerasure_sohandle) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
alg_sig_handle = (alg_sig_t *)malloc(sizeof(alg_sig_t));
|
||||
if (alg_sig_handle == NULL) {
|
||||
if (NULL == alg_sig_handle) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -176,6 +170,13 @@ alg_sig_t *init_alg_sig_w16(int sig_len)
|
||||
alg_sig_t *init_alg_sig(int sig_len, int gf_w)
|
||||
{
|
||||
int i=0;
|
||||
void *jerasure_sohandle = get_jerasure_sohandle();
|
||||
|
||||
if (NULL == jerasure_sohandle) {
|
||||
fprintf (stderr, "Could not open Jerasure backend. Install Jerasure or fix LD_LIBRARY_PATH. Passing.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (valid_pairs[i][0] > -1) {
|
||||
if (gf_w == valid_pairs[i][0] &&
|
||||
sig_len == valid_pairs[i][1]) {
|
||||
@@ -189,9 +190,9 @@ alg_sig_t *init_alg_sig(int sig_len, int gf_w)
|
||||
}
|
||||
|
||||
if (gf_w == 8) {
|
||||
return init_alg_sig_w8(sig_len);
|
||||
return init_alg_sig_w8(jerasure_sohandle, sig_len);
|
||||
} else if (gf_w == 16) {
|
||||
return init_alg_sig_w16(sig_len);
|
||||
return init_alg_sig_w16(jerasure_sohandle, sig_len);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ check_PROGRAMS = test_xor_hd_code
|
||||
alg_sig_test_SOURCES = utils/chksum/test_alg_sig.c
|
||||
alg_sig_test_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/erasurecode -I$(top_srcdir)/include/xor_codes
|
||||
alg_sig_test_LDFLAGS = -static-libtool-libs $(top_srcdir)/src/liberasurecode.la -ldl
|
||||
# check_PROGRAMS += alg_sig_test
|
||||
check_PROGRAMS += alg_sig_test
|
||||
|
||||
liberasurecode_test_SOURCES = liberasurecode_test.c
|
||||
liberasurecode_test_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/erasurecode
|
||||
|
||||
@@ -159,8 +159,9 @@ int main(int argc, char **argv)
|
||||
for (ii = 0; testcases[ii].description != NULL; ++ii) {
|
||||
fflush(stdout);
|
||||
if (testcases[ii].skip) {
|
||||
fprintf(stdout, "ok # SKIP %d - %s\n", ii + 1,
|
||||
testcases[ii].description);
|
||||
fprintf(stdout, "ok # SKIP %d - %s: %s\n", ii + 1,
|
||||
testcases[ii].description,
|
||||
(const char *) testcases[ii].arg1);
|
||||
continue;
|
||||
}
|
||||
testcases[ii].function(testcases[ii].arg1, testcases[ii].arg2);
|
||||
|
||||
@@ -83,7 +83,6 @@ out:
|
||||
|
||||
static int basic_xor_test_8_32()
|
||||
{
|
||||
alg_sig_t* sig_handle = init_alg_sig(32, 8);
|
||||
int blocksize = 65536;
|
||||
int num_data = 12;
|
||||
char **data;
|
||||
@@ -92,6 +91,10 @@ static int basic_xor_test_8_32()
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
alg_sig_t* sig_handle = init_alg_sig(32, 8);
|
||||
if (NULL == sig_handle) {
|
||||
goto out;
|
||||
}
|
||||
data = (char**)malloc(sizeof(char*) * num_data);
|
||||
sigs = (char**)malloc(sizeof(char*) * (num_data + 1));
|
||||
for (i=0; i < num_data; i++) {
|
||||
@@ -125,12 +128,12 @@ static int basic_xor_test_8_32()
|
||||
free(data);
|
||||
destroy_alg_sig(sig_handle);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int basic_xor_test_16_64()
|
||||
{
|
||||
alg_sig_t* sig_handle = init_alg_sig(64, 16);
|
||||
int blocksize = 65536;
|
||||
int num_data = 12;
|
||||
char **data;
|
||||
@@ -139,6 +142,11 @@ static int basic_xor_test_16_64()
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
alg_sig_t* sig_handle = init_alg_sig(64, 16);
|
||||
if (NULL == sig_handle) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
data = (char**)malloc(sizeof(char*) * num_data);
|
||||
sigs = (char**)malloc(sizeof(char*) * (num_data + 1));
|
||||
for (i=0; i < num_data; i++) {
|
||||
@@ -171,13 +179,12 @@ static int basic_xor_test_16_64()
|
||||
free(data);
|
||||
destroy_alg_sig(sig_handle);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
static int basic_xor_test_16_32()
|
||||
{
|
||||
alg_sig_t* sig_handle = init_alg_sig(32, 16);
|
||||
int blocksize = 65536;
|
||||
int num_data = 12;
|
||||
char **data;
|
||||
@@ -186,6 +193,10 @@ static int basic_xor_test_16_32()
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
alg_sig_t* sig_handle = init_alg_sig(32, 16);
|
||||
if (NULL == sig_handle) {
|
||||
goto out;
|
||||
}
|
||||
data = (char**)malloc(sizeof(char*) * num_data);
|
||||
sigs = (char**)malloc(sizeof(char*) * (num_data + 1));
|
||||
for (i=0; i < num_data; i++) {
|
||||
@@ -219,6 +230,7 @@ static int basic_xor_test_16_32()
|
||||
free(data);
|
||||
destroy_alg_sig(sig_handle);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user