summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp>2016-12-01 21:35:31 -0800
committerKota Tsuyuzaki <tsuyuzaki.kota@lab.ntt.co.jp>2016-12-04 20:56:24 -0800
commit09d8bbf361955b986fbcbf172dfbef2ed78d5f24 (patch)
treef673bdc2dd0652402afa074c375e02dfdb71798f
parent0a2c06b8b446cbe4fda89c18c20b069728c70323 (diff)
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
Notes
Notes (review): Code-Review+2: Tim Burke <tim@swiftstack.com> Code-Review+2: Thiago da Silva <thiago@redhat.com> Workflow+1: Thiago da Silva <thiago@redhat.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 08 Dec 2016 19:54:37 +0000 Reviewed-on: https://review.openstack.org/405926 Project: openstack/liberasurecode Branch: refs/heads/master
-rw-r--r--include/erasurecode/erasurecode.h8
-rw-r--r--src/erasurecode.c10
-rw-r--r--test/liberasurecode_test.c9
3 files changed, 27 insertions, 0 deletions
diff --git a/include/erasurecode/erasurecode.h b/include/erasurecode/erasurecode.h
index a17c45c..e5a6c93 100644
--- a/include/erasurecode/erasurecode.h
+++ b/include/erasurecode/erasurecode.h
@@ -375,6 +375,14 @@ int liberasurecode_get_minimum_encode_size(int desc);
375 */ 375 */
376int liberasurecode_get_fragment_size(int desc, int data_len); 376int liberasurecode_get_fragment_size(int desc, int data_len);
377 377
378/**
379 * This will return the liberasurecode version for the descriptor
380 *
381 * @return version uint32_t - from erasurecode_version.h
382 */
383
384uint32_t liberasurecode_get_version();
385
378/* ==~=*=~===~=*=~==~=*=~== liberasurecode Error codes =~=*=~==~=~=*=~==~== */ 386/* ==~=*=~===~=*=~==~=*=~== liberasurecode Error codes =~=*=~==~=~=*=~==~== */
379 387
380/* Error codes */ 388/* Error codes */
diff --git a/src/erasurecode.c b/src/erasurecode.c
index d3b3cea..4f3419c 100644
--- a/src/erasurecode.c
+++ b/src/erasurecode.c
@@ -1232,6 +1232,16 @@ int liberasurecode_get_fragment_size(int desc, int data_len)
1232 return size; 1232 return size;
1233} 1233}
1234 1234
1235
1236/**
1237 * This will return the liberasurecode version for the descriptor
1238 */
1239
1240uint32_t liberasurecode_get_version()
1241{
1242 return LIBERASURECODE_VERSION;
1243}
1244
1235/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=* misc *=~==~=*=~==~=*=~==~=*=~==~=*=~== */ 1245/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=* misc *=~==~=*=~==~=*=~==~=*=~==~=*=~== */
1236 1246
1237#if 0 1247#if 0
diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c
index 386d49f..3a6cf36 100644
--- a/test/liberasurecode_test.c
+++ b/test/liberasurecode_test.c
@@ -903,6 +903,11 @@ static void test_get_fragment_partition()
903 free(orig_data); 903 free(orig_data);
904} 904}
905 905
906static void test_liberasurecode_get_version(){
907 uint32_t version = liberasurecode_get_version();
908 assert(version == LIBERASURECODE_VERSION);
909}
910
906static void encode_decode_test_impl(const ec_backend_id_t be_id, 911static void encode_decode_test_impl(const ec_backend_id_t be_id,
907 struct ec_args *args, 912 struct ec_args *args,
908 int *skip) 913 int *skip)
@@ -1694,6 +1699,10 @@ struct testcase testcases[] = {
1694 test_get_fragment_partition, 1699 test_get_fragment_partition,
1695 EC_BACKENDS_MAX, CHKSUM_TYPES_MAX, 1700 EC_BACKENDS_MAX, CHKSUM_TYPES_MAX,
1696 .skip = false}, 1701 .skip = false},
1702 {"test_liberasurecode_get_version",
1703 test_liberasurecode_get_version,
1704 EC_BACKENDS_MAX, CHKSUM_TYPES_MAX,
1705 .skip = false},
1697 // NULL backend test 1706 // NULL backend test
1698 {"create_and_destroy_backend", 1707 {"create_and_destroy_backend",
1699 test_create_and_destroy_backend, 1708 test_create_and_destroy_backend,