summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKevin Greenan <kmg@box.com>2015-03-30 13:51:45 -0700
committerKevin Greenan <kmg@box.com>2015-03-30 15:23:22 -0700
commit0d1e4136aebcef230be62374a002e2e05a46237e (patch)
treeca7c9ce0655b2ba17a86cffb2f57eff46ea19d6d /test
parentc10ec8a255eaca5c8637a46c3be4f22c707675c7 (diff)
downloadliberasurecode-0d1e4136aebcef230be62374a002e2e05a46237e.tar.gz
Fix nasty rebuild bug where partiy would be reconstructed incorrectly
when both data and parity was missing. The fix is to just call decode when reconstructing parity, since it will have to do extra work anyway when data is missing. We did a little extra work in ISA-L to do better, but can save that for later, since 99% of the time decode will perform just fine.
Diffstat (limited to 'test')
-rw-r--r--test/liberasurecode_test.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c
index d1ad516..dc112f9 100644
--- a/test/liberasurecode_test.c
+++ b/test/liberasurecode_test.c
@@ -768,6 +768,17 @@ static void encode_decode_test_impl(const ec_backend_id_t be_id,
free(avail_frags);
}
+/**
+ * Note: this test will attempt to reconstruct a single fragment when
+ * one or more other fragments are missing (specified by skip).
+ *
+ * For example, if skip is [0, 0, 0, 1, 0, 0] and we are reconstructing
+ * fragment 5, then it will test the reconstruction of fragment 5 when 3
+ * and 5 are assumed unavailable.
+ *
+ * We only mark at most 2 as unavailable, as we cannot guarantee every situation
+ * will be able to habndle 3 failures.
+ */
static void reconstruct_test_impl(const ec_backend_id_t be_id,
struct ec_args *args,
int *skip)
@@ -796,15 +807,24 @@ static void reconstruct_test_impl(const ec_backend_id_t be_id,
rc = liberasurecode_encode(desc, orig_data, orig_data_size,
&encoded_data, &encoded_parity, &encoded_fragment_len);
assert(rc == 0);
- num_avail_frags = create_frags_array(&avail_frags, encoded_data,
- encoded_parity, args, skip);
out = malloc(encoded_fragment_len);
assert(out != NULL);
for (i = 0; i < num_fragments; i++) {
+ char *cmp = NULL;
+ // If the current fragment was not chosen as fragments to skip,
+ // remove it and the chosen fragments to skip from the available list
+ // and reset its state
if (skip[i] == 0) {
- continue;
+ skip[i] = 1;
+ num_avail_frags = create_frags_array(&avail_frags, encoded_data,
+ encoded_parity, args, skip);
+ skip[i] = 0;
+ // Do not reset the skip state if the fragment was chosen as a fragment
+ // to skip for this invocation of the test
+ } else {
+ num_avail_frags = create_frags_array(&avail_frags, encoded_data,
+ encoded_parity, args, skip);
}
- char *cmp = NULL;
if (i < args->k) {
cmp = encoded_data[i];
}