diff --git a/cmdline/selftest.c b/cmdline/selftest.c index 30b2db4d..76c0d323 100644 --- a/cmdline/selftest.c +++ b/cmdline/selftest.c @@ -1097,7 +1097,6 @@ static void test_stream(void) } } - void selftest(void) { log_tag("selftest:\n"); @@ -1127,9 +1126,24 @@ void selftest(void) test_wnmatch(); test_parse_smartctl(); test_smart_ignore(); + raid_mode(RAID_MODE_CAUCHY_RAID); if (raid_selftest() != 0) { /* LCOV_EXCL_START */ - log_fatal(EINTERNAL, "Failed SELF test\n"); + log_fatal(EINTERNAL, "Failed SELF Cauchy RAID test\n"); + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + raid_mode(RAID_MODE_CAUCHY_AES); + if (raid_selftest() != 0) { + /* LCOV_EXCL_START */ + log_fatal(EINTERNAL, "Failed SELF Cauchy AES test\n"); + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + raid_mode(RAID_MODE_VANDERMONDE_RAID); + if (raid_selftest() != 0) { + /* LCOV_EXCL_START */ + log_fatal(EINTERNAL, "Failed SELF Vandermonde RAID test\n"); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } @@ -1212,7 +1226,7 @@ void selftest(void) /* LCOV_EXCL_STOP */ } - /* Verify raid_mode get/set behavior */ + /* verify raid_mode get/set behavior */ int cur = raid_mode(RAID_MODE_GET); int prev = raid_mode(RAID_MODE_CAUCHY_AES); if (prev != cur) { @@ -1227,6 +1241,8 @@ void selftest(void) exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } - raid_mode(prev); + + /* restore default mode */ + raid_mode(RAID_MODE_CAUCHY_RAID); } diff --git a/raid/module.c b/raid/module.c index de5e6256..3ca187f3 100644 --- a/raid/module.c +++ b/raid/module.c @@ -564,11 +564,18 @@ int raid_selftest(void) int ir[RAID_PARITY_MAX]; int ip[RAID_PARITY_MAX]; int i, np; + int np_max; int ret = 0; /* ensure to have enough space for data */ BUG_ON(nd * size > 65536); + /* vandermonde mode only supports up to 3 parity rows */ + if (raid_mode_active == RAID_MODE_VANDERMONDE_RAID) + np_max = 3; + else + np_max = RAID_PARITY_MAX; + v = raid_malloc_vector(nv, size, &v_alloc); if (!v) { /* LCOV_EXCL_START */ @@ -584,14 +591,14 @@ int raid_selftest(void) ref[i] = ((uint8_t *)raid_gfmul) + size * i; /* setup reference parity */ - for (i = 0; i < RAID_PARITY_MAX; ++i) + for (i = 0; i < np_max; ++i) ref[nd + i] = v[nd + RAID_PARITY_MAX + i]; /* compute reference parity */ - raid_gen_ref(nd, RAID_PARITY_MAX, size, ref); + raid_gen_ref(nd, np_max, size, ref); /* test for each parity level */ - for (np = 1; np <= RAID_PARITY_MAX; ++np) { + for (np = 1; np <= np_max; ++np) { /* test parity generation */ ret = raid_test_par(nd, np, size, v, ref); if (ret != 0) { diff --git a/raid/test/selftest.c b/raid/test/selftest.c index b68d36df..a7cf4857 100644 --- a/raid/test/selftest.c +++ b/raid/test/selftest.c @@ -29,6 +29,7 @@ int main(void) goto bail; /* LCOV_EXCL_STOP */ } + raid_mode(RAID_MODE_CAUCHY_RAID); if (raid_selftest() != 0) { /* LCOV_EXCL_START */ goto bail; @@ -41,12 +42,23 @@ int main(void) goto bail; /* LCOV_EXCL_STOP */ } + raid_mode(RAID_MODE_CAUCHY_AES); if (raid_selftest() != 0) { /* LCOV_EXCL_START */ goto bail; /* LCOV_EXCL_STOP */ } + printf("Test Vandermonde RAID\n"); + raid_mode(RAID_MODE_VANDERMONDE_RAID); + if (raid_selftest() != 0) { + /* LCOV_EXCL_START */ + goto bail; + /* LCOV_EXCL_STOP */ + } + + raid_mode(RAID_MODE_CAUCHY_RAID); + printf("OK\n"); return 0;