mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Extend the raid coverage test
This commit is contained in:
parent
7fd0beb36a
commit
a60e7a9bb5
5 changed files with 136 additions and 27 deletions
|
|
@ -21,8 +21,11 @@ void *raid_malloc_align(size_t size, void **freeptr)
|
|||
uintptr_t offset;
|
||||
|
||||
ptr = malloc(size + RAID_MALLOC_ALIGN);
|
||||
if (!ptr)
|
||||
if (!ptr) {
|
||||
/* LCOV_EXCL_START */
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
*freeptr = ptr;
|
||||
|
||||
|
|
@ -43,13 +46,18 @@ void **raid_malloc_vector(int nd, int n, size_t size, void **freeptr)
|
|||
BUG_ON(n <= 0 || nd < 0);
|
||||
|
||||
v = malloc(n * sizeof(void *));
|
||||
if (!v)
|
||||
if (!v) {
|
||||
/* LCOV_EXCL_START */
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
va = raid_malloc_align(n * (size + RAID_MALLOC_DISPLACEMENT), freeptr);
|
||||
if (!va) {
|
||||
/* LCOV_EXCL_START */
|
||||
free(v);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
|
|
@ -107,8 +115,11 @@ int raid_mtest_vector(int n, size_t size, void **vv)
|
|||
/* forward fill */
|
||||
for (i = 0; i < n; ++i) {
|
||||
for (j = 0; j < size; ++j) {
|
||||
if (v[i][j] != p)
|
||||
if (v[i][j] != p) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
v[i][j] = d;
|
||||
}
|
||||
}
|
||||
|
|
@ -118,8 +129,11 @@ int raid_mtest_vector(int n, size_t size, void **vv)
|
|||
/* backward fill with complement */
|
||||
for (i = 0; i < n; ++i) {
|
||||
for (j = size; j > 0; --j) {
|
||||
if (v[i][j - 1] != p)
|
||||
if (v[i][j - 1] != p) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
v[i][j - 1] = d;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,9 @@ static int raid_test_par(int nd, int np, size_t size, void **v, void **ref)
|
|||
/* compare parity */
|
||||
for (i = 0; i < np; ++i) {
|
||||
if (memcmp(t[nd + i], ref[nd + i], size) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +202,9 @@ static int raid_test_rec(int nr, int *ir, int nd, int np, size_t size, void **v,
|
|||
for (i = 0; i < nd + np; ++i) {
|
||||
if (t[i] != ref[i]
|
||||
&& memcmp(t[i], ref[i], size) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +250,9 @@ static int raid_test_rec_dataonly(int nr, int *id, int *ip, int nd, int np, size
|
|||
if (t[i] != ref[i]
|
||||
&& t[i] != 0
|
||||
&& memcmp(t[i], ref[i], size) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -273,8 +279,11 @@ int raid_selftest(void)
|
|||
BUG_ON(nd * size > 65536);
|
||||
|
||||
v = raid_malloc_vector(nd, nv, size, &v_alloc);
|
||||
if (!v)
|
||||
if (!v) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
memset(v[nv - 1], 0, size);
|
||||
raid_zero(v[nv - 1]);
|
||||
|
|
@ -294,8 +303,11 @@ int raid_selftest(void)
|
|||
for (np = 1; np <= RAID_PARITY_MAX; ++np) {
|
||||
/* test parity generation */
|
||||
ret = raid_test_par(nd, np, size, v, ref);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* test recovering with broken ending data disks */
|
||||
for (i = 0; i < np; ++i) {
|
||||
|
|
@ -307,12 +319,18 @@ int raid_selftest(void)
|
|||
}
|
||||
|
||||
ret = raid_test_rec(np, ir, nd, np, size, v, ref);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
ret = raid_test_rec_dataonly(np, ir, ip, nd, np, size, v, ref);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* test recovering with broken leading data and broken leading parity */
|
||||
for (i = 0; i < np / 2; ++i) {
|
||||
|
|
@ -328,12 +346,18 @@ int raid_selftest(void)
|
|||
ir[np / 2 + i] = nd + i;
|
||||
|
||||
ret = raid_test_rec(np, ir, nd, np, size, v, ref);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
ret = raid_test_rec_dataonly(np / 2, ir, ip, nd, np, size, v, ref);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* test recovering with broken leading data and broken ending parity */
|
||||
for (i = 0; i < np / 2; ++i) {
|
||||
|
|
@ -349,12 +373,18 @@ int raid_selftest(void)
|
|||
ir[np / 2 + i] = nd + np - (np + 1) / 2 + i;
|
||||
|
||||
ret = raid_test_rec(np, ir, nd, np, size, v, ref);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
ret = raid_test_rec_dataonly(np / 2, ir, ip, nd, np, size, v, ref);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
bail:
|
||||
|
|
|
|||
|
|
@ -87,7 +87,10 @@ static const char *raid_tag(void *func)
|
|||
return i->name;
|
||||
++i;
|
||||
}
|
||||
|
||||
/* LCOV_EXCL_START */
|
||||
return "unknown";
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
const char *raid_gen1_tag(void)
|
||||
|
|
|
|||
61
raid/test.c
61
raid/test.c
|
|
@ -58,8 +58,11 @@ int raid_test_combo(void)
|
|||
++count;
|
||||
} while (combination_next(r, RAID_PARITY_MAX, p));
|
||||
|
||||
if (count != ibc(RAID_PARITY_MAX, r))
|
||||
if (count != ibc(RAID_PARITY_MAX, r)) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
for (r = 1; r <= RAID_PARITY_MAX; ++r) {
|
||||
|
|
@ -71,8 +74,11 @@ int raid_test_combo(void)
|
|||
++count;
|
||||
} while (permutation_next(r, RAID_PARITY_MAX, p));
|
||||
|
||||
if (count != ipow(RAID_PARITY_MAX, r))
|
||||
if (count != ipow(RAID_PARITY_MAX, r)) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -94,9 +100,13 @@ int raid_test_insert(void)
|
|||
raid_insert(j, i, p[j]);
|
||||
|
||||
/* check order */
|
||||
for (j = 1; j < r; ++j)
|
||||
if (i[j - 1] > i[j])
|
||||
for (j = 1; j < r; ++j) {
|
||||
if (i[j - 1] > i[j]) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
} while (permutation_next(r, RAID_PARITY_MAX, p));
|
||||
}
|
||||
|
||||
|
|
@ -121,9 +131,13 @@ int raid_test_sort(void)
|
|||
raid_sort(r, i);
|
||||
|
||||
/* check order */
|
||||
for (j = 1; j < r; ++j)
|
||||
if (i[j - 1] > i[j])
|
||||
for (j = 1; j < r; ++j) {
|
||||
if (i[j - 1] > i[j]) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
} while (permutation_next(r, RAID_PARITY_MAX, p));
|
||||
}
|
||||
|
||||
|
|
@ -160,8 +174,11 @@ int raid_test_rec(int mode, int nd, size_t size)
|
|||
nv = nd + np * 2 + 2;
|
||||
|
||||
v = raid_malloc_vector(nd, nv, size, &v_alloc);
|
||||
if (!v)
|
||||
if (!v) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
data = v;
|
||||
parity = v + nd;
|
||||
|
|
@ -250,9 +267,13 @@ int raid_test_rec(int mode, int nd, size_t size)
|
|||
f[nr - 1][j](nr, id, ip, nd, size, v);
|
||||
|
||||
/* check */
|
||||
for (i = 0; i < nr; ++i)
|
||||
if (memcmp(test[i], data_save[i], size) != 0)
|
||||
for (i = 0; i < nr; ++i) {
|
||||
if (memcmp(test[i], data_save[i], size) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
/* restore */
|
||||
for (i = 0; i < nr; ++i) {
|
||||
|
|
@ -271,9 +292,11 @@ int raid_test_rec(int mode, int nd, size_t size)
|
|||
return 0;
|
||||
|
||||
bail:
|
||||
/* LCOV_EXCL_START */
|
||||
free(v_alloc);
|
||||
free(v);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
int raid_test_par(int mode, int nd, size_t size)
|
||||
|
|
@ -295,12 +318,18 @@ int raid_test_par(int mode, int nd, size_t size)
|
|||
nv = nd + np * 2;
|
||||
|
||||
v = raid_malloc_vector(nd, nv, size, &v_alloc);
|
||||
if (!v)
|
||||
if (!v) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* check memory */
|
||||
if (raid_mtest_vector(nv, size, v) != 0)
|
||||
if (raid_mtest_vector(nv, size, v) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* fill with pseudo-random data with the arbitrary seed "2" */
|
||||
raid_mrand_vector(2, nv, size, v);
|
||||
|
|
@ -401,9 +430,13 @@ int raid_test_par(int mode, int nd, size_t size)
|
|||
f[j](nd, size, v);
|
||||
|
||||
/* check it */
|
||||
for (i = 0; i < np; ++i)
|
||||
if (memcmp(v[nd + np + i], v[nd + i], size) != 0)
|
||||
for (i = 0; i < np; ++i) {
|
||||
if (memcmp(v[nd + np + i], v[nd + i], size) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(v_alloc);
|
||||
|
|
@ -411,8 +444,10 @@ int raid_test_par(int mode, int nd, size_t size)
|
|||
return 0;
|
||||
|
||||
bail:
|
||||
/* LCOV_EXCL_START */
|
||||
free(v_alloc);
|
||||
free(v);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,22 @@
|
|||
# invtest - Runs an extensive matrix inversion test of all the 377.342.351.231
|
||||
# possible square submatrices of the Cauchy matrix used.
|
||||
# covtest - Runs a coverage test.
|
||||
# sdecovtest - Runs a coverage test with the sde emulator.
|
||||
#
|
||||
|
||||
MACHINE = $(shell uname -m)
|
||||
ifeq ($(MACHINE),i686)
|
||||
SDE = sde
|
||||
else
|
||||
SDE = sde64
|
||||
endif
|
||||
CC = gcc
|
||||
LD = ld
|
||||
CFLAGS = -I.. -Wall -Wextra -g
|
||||
ifeq ($(COVERAGE),)
|
||||
CFLAGS += -O2
|
||||
else
|
||||
CFLAGS += -O0 --coverage -DCOVERAGE=1
|
||||
CFLAGS += -O0 --coverage -DCOVERAGE=1 -DNDEBUG=1
|
||||
endif
|
||||
OBJS = raid.o int.o intz.o x86.o x86z.o tables.o memory.o test.o helper.o module.o tag.o
|
||||
|
||||
|
|
@ -53,6 +60,23 @@ covtest:
|
|||
$(MAKE) lcov_capture
|
||||
$(MAKE) lcov_html
|
||||
|
||||
# Use this target to run a coverage test using lcov and the sde
|
||||
sdecovtest:
|
||||
$(MAKE) clean
|
||||
$(MAKE) lcov_reset
|
||||
$(MAKE) COVERAGE=1 all
|
||||
$(SDE) -p4 -- ./fulltest
|
||||
$(SDE) -mrm -- ./fulltest
|
||||
$(SDE) -nhm -- ./fulltest
|
||||
$(SDE) -hsw -- ./fulltest
|
||||
$(SDE) -p4 -- ./selftest
|
||||
$(SDE) -mrm -- ./selftest
|
||||
$(SDE) -nhm -- ./selftest
|
||||
$(SDE) -hsw -- ./selftest
|
||||
$(SDE) -hsw -- ./speedtest
|
||||
$(MAKE) lcov_capture
|
||||
$(MAKE) lcov_html
|
||||
|
||||
lcov_reset:
|
||||
lcov --directory . -z
|
||||
rm -f lcov.info
|
||||
|
|
@ -66,7 +90,10 @@ lcov_html:
|
|||
genhtml --branch-coverage -o coverage lcov.info
|
||||
|
||||
clean:
|
||||
rm -f *.o mktables fulltest speedtest selftest invtest
|
||||
rm -f *.o mktables tables.c
|
||||
rm -f *.gcda *.gcno lcov.info
|
||||
rm -rf coverage
|
||||
|
||||
distclean: clean
|
||||
rm -f fulltest speedtest selftest invtest
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue