Add get_version functionality to liberasurecode lib

Currently, we have liberasurecode version info in the header and pyeclib
is using the info to detect the version. However it's a bit painful
because it requires to rebuild pyeclib c code for you to see the actual
installed version.

This addition for liberasurecode_get_version enables caller to get the
version integer from compiled shared library file (.so) and it will
rescure to re-compiled operation from pyeclib.

Change-Id: I8161ea7da3b069e83c93e11cb41ce12fa60c6f32
This commit is contained in:
Kota Tsuyuzaki 2016-12-01 21:35:31 -08:00
parent 0a2c06b8b4
commit 09d8bbf361
3 changed files with 27 additions and 0 deletions

View File

@ -375,6 +375,14 @@ int liberasurecode_get_minimum_encode_size(int desc);
*/
int liberasurecode_get_fragment_size(int desc, int data_len);
/**
* This will return the liberasurecode version for the descriptor
*
* @return version uint32_t - from erasurecode_version.h
*/
uint32_t liberasurecode_get_version();
/* ==~=*=~===~=*=~==~=*=~== liberasurecode Error codes =~=*=~==~=~=*=~==~== */
/* Error codes */

View File

@ -1232,6 +1232,16 @@ int liberasurecode_get_fragment_size(int desc, int data_len)
return size;
}
/**
* This will return the liberasurecode version for the descriptor
*/
uint32_t liberasurecode_get_version()
{
return LIBERASURECODE_VERSION;
}
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=* misc *=~==~=*=~==~=*=~==~=*=~==~=*=~== */
#if 0

View File

@ -903,6 +903,11 @@ static void test_get_fragment_partition()
free(orig_data);
}
static void test_liberasurecode_get_version(){
uint32_t version = liberasurecode_get_version();
assert(version == LIBERASURECODE_VERSION);
}
static void encode_decode_test_impl(const ec_backend_id_t be_id,
struct ec_args *args,
int *skip)
@ -1694,6 +1699,10 @@ struct testcase testcases[] = {
test_get_fragment_partition,
EC_BACKENDS_MAX, CHKSUM_TYPES_MAX,
.skip = false},
{"test_liberasurecode_get_version",
test_liberasurecode_get_version,
EC_BACKENDS_MAX, CHKSUM_TYPES_MAX,
.skip = false},
// NULL backend test
{"create_and_destroy_backend",
test_create_and_destroy_backend,