diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-09-13 21:33:43 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-09-13 21:33:43 +0000 |
commit | d81c49161b093715e690f9aa82020f729a44be7a (patch) | |
tree | f2f944acb77c99e8901536e916d23e11c6d9358a | |
parent | 3ff4b22bc149f3c5e89c21cb3038b0fc9dc4378d (diff) | |
parent | cf12c9ca26e4388e383f1aa3c1558d61eda96777 (diff) | |
download | liberasurecode-d81c49161b093715e690f9aa82020f729a44be7a.tar.gz |
Merge "flat_xor_hd: better validate args"
-rw-r--r-- | src/builtin/xor_codes/xor_hd_code.c | 2 | ||||
-rw-r--r-- | test/liberasurecode_test.c | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/builtin/xor_codes/xor_hd_code.c b/src/builtin/xor_codes/xor_hd_code.c index 5c4d052..9e41ad1 100644 --- a/src/builtin/xor_codes/xor_hd_code.c +++ b/src/builtin/xor_codes/xor_hd_code.c @@ -664,7 +664,7 @@ xor_code_t* init_xor_hd_code(int k, int m, int hd) if (k <= 10 && k >= 5) { is_valid = 1; } - } else if (m == 3) { + } else if (m == 3 && k == 3) { is_valid = 1; } } diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c index 74aef9a..b837baa 100644 --- a/test/liberasurecode_test.c +++ b/test/liberasurecode_test.c @@ -1536,6 +1536,28 @@ static void test_jerasure_rs_cauchy_init_failure() assert(-EBACKENDINITERR == desc); } +static void test_flat_xor_hd3_init_failure() +{ + struct ec_args bad_args[] = { + {.k = 1, .m = 5, .hd=3}, + {.k = 5, .m = 1, .hd=3}, + {.k = 4, .m = 4, .hd=3}, + {.k = 1, .m = 3, .hd=3}, + {.k = 4, .m = 3, .hd=3}, + }; + + for (int i = 0; i < sizeof(bad_args)/sizeof(bad_args[0]); ++i) { + int desc = -1; + desc = liberasurecode_instance_create( + EC_BACKEND_FLAT_XOR_HD, &bad_args[i]); + if (-EBACKENDNOTAVAIL == desc) { + fprintf (stderr, "Backend library not available!\n"); + return; + } + assert(-EBACKENDINITERR == desc); + } +} + static void test_simple_encode_decode(const ec_backend_id_t be_id, struct ec_args *args) { @@ -1819,6 +1841,7 @@ struct testcase testcases[] = { TEST(test_decode_with_missing_multi_parity, EC_BACKEND_NULL, CHKSUM_NONE), // Flat XOR backend tests TEST_SUITE(EC_BACKEND_FLAT_XOR_HD), + TEST(test_flat_xor_hd3_init_failure, EC_BACKENDS_MAX, 0), // Jerasure RS Vand backend tests TEST_SUITE(EC_BACKEND_JERASURE_RS_VAND), TEST(test_jerasure_rs_vand_simple_encode_decode_over32, EC_BACKENDS_MAX, 0), |