summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTushar Gohad <tushar.gohad@intel.com>2014-07-22 18:25:30 -0700
committerTushar Gohad <tushar.gohad@intel.com>2014-07-22 18:25:30 -0700
commit5b393fab81a3326553827ab7b1cda0ca008468a0 (patch)
tree5a86a722f8964ca9f5c1da11d851f51b2c76fc1a
parente96f00ee117b936bd54ed04494122eca575ca066 (diff)
downloadliberasurecode-5b393fab81a3326553827ab7b1cda0ca008468a0.tar.gz
algsig: Move jerasure backend dlopen up a level
.. also check for errors Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
-rw-r--r--Makefile.am4
-rw-r--r--include/config.h.in9
-rw-r--r--src/utils/chksum/alg_sig.c31
-rw-r--r--test/Makefile.am2
-rw-r--r--test/liberasurecode_test.c5
-rw-r--r--test/utils/chksum/test_alg_sig.c20
6 files changed, 38 insertions, 33 deletions
diff --git a/Makefile.am b/Makefile.am
index b742621..d071c47 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/include/config.h.in b/include/config.h.in
index c55b014..d3f4b67 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -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
diff --git a/src/utils/chksum/alg_sig.c b/src/utils/chksum/alg_sig.c
index f8329b8..bfaa4a1 100644
--- a/src/utils/chksum/alg_sig.c
+++ b/src/utils/chksum/alg_sig.c
@@ -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;
}
diff --git a/test/Makefile.am b/test/Makefile.am
index 6003bbc..5f9db05 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -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
diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c
index 670e296..7de3956 100644
--- a/test/liberasurecode_test.c
+++ b/test/liberasurecode_test.c
@@ -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);
diff --git a/test/utils/chksum/test_alg_sig.c b/test/utils/chksum/test_alg_sig.c
index dfa1005..a0ddf4b 100644
--- a/test/utils/chksum/test_alg_sig.c
+++ b/test/utils/chksum/test_alg_sig.c
@@ -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;
}