summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKota Tsuyuzaki <bloodeagle40234@gmail.com>2015-02-05 21:54:38 -0800
committerKota Tsuyuzaki <bloodeagle40234@gmail.com>2015-02-27 04:54:50 -0800
commit0addebdbf6ea54a6bfbf606175fbdd5fa8481806 (patch)
tree2772f9e62b89e33fe260b0f656af1c1548486442 /test
parent1b08cb43768d34d859a0b180ce69c3cb02f75a34 (diff)
downloadliberasurecode-0addebdbf6ea54a6bfbf606175fbdd5fa8481806.tar.gz
Enable to get fragment_len includes metadata_adder
This patch allows to get correct fragment size includes metadata_adder. Current implementaion automatically allocates extra bytes for the metadata_adder in alloc_buffer, and then, no information about the extra bytes will be returned to the api caller side. It's too confusable because callers couldn't know how size they assumes as the fragment size. To be easy to find out the size infomation, this patch adds "frag_adder_size" variable into fragment metadata and also some functions to get fragment size. The definitions of these size infomation are here, fragment_meta: - size-> raw data size used to encode/fragment_to_string - frag_adder_size-> metadata_adder of backend specification And the definitions of functions are here, - get_fragment_size: -> return sizeof(fragument_header) + size + frag_adder_size - get_fragment_buffer_size: -> return size + frag_adder_size - get_fragment_payload_size: -> return size By using these function above, users could get the size information directly from fragments. It results in enabling to return fragment_len to the caller side easily.
Diffstat (limited to 'test')
-rw-r--r--test/liberasurecode_test.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c
index 04d06cf..3d9ef6c 100644
--- a/test/liberasurecode_test.c
+++ b/test/liberasurecode_test.c
@@ -592,8 +592,11 @@ static void encode_decode_test_impl(const ec_backend_id_t be_id,
int num_avail_frags = 0;
char *orig_data_ptr = NULL;
int remaining = 0;
+ ec_backend_t be = NULL;
desc = liberasurecode_instance_create(be_id, args);
+ be = liberasurecode_backend_instance_get_by_desc(desc);
+
if (-EBACKENDNOTAVAIL == desc) {
fprintf (stderr, "Backend library not available!\n");
return;
@@ -614,7 +617,7 @@ static void encode_decode_test_impl(const ec_backend_id_t be_id,
assert(header != NULL);
fragment_metadata_t metadata = header->meta;
assert(metadata.idx == i);
- assert(metadata.size == encoded_fragment_len - frag_header_size);
+ assert(metadata.size == encoded_fragment_len - frag_header_size - be->common.metadata_adder);
assert(metadata.orig_data_size == orig_data_size);
char *data_ptr = frag + frag_header_size;
int cmp_size = remaining >= metadata.size ? metadata.size : remaining;