From 0ac0a8ecebd5cbb7016b917826788931900af3a5 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 30 Mar 2015 18:57:33 +0200 Subject: [PATCH] Extend the raid regression test with some more case --- raid/check.c | 2 +- raid/module.c | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/raid/check.c b/raid/check.c index 6b754345..9bed9337 100644 --- a/raid/check.c +++ b/raid/check.c @@ -165,7 +165,7 @@ int raid_scan(int *ir, int nd, int np, size_t size, void **v) int r; /* check the special case of no failure */ - if (raid_check(0, 0, nd, np, size, v) == 0) + if (np != 0 && raid_check(0, 0, nd, np, size, v) == 0) return 0; /* for each number of possible failures */ diff --git a/raid/module.c b/raid/module.c index e23d9617..4cf457f6 100644 --- a/raid/module.c +++ b/raid/module.c @@ -274,9 +274,6 @@ static int raid_test_scan(int nr, int *ir, int nd, int np, size_t size, void **v /* this block is bad */ t[i] = v[i]; ++j; - - /* make it really bad */ - memset(t[i], i, size); } else { /* this block is used for recovering */ t[i] = ref[i]; @@ -286,11 +283,8 @@ static int raid_test_scan(int nr, int *ir, int nd, int np, size_t size, void **v ret = raid_scan(is, nd, np, size, t); /* compare identified bad blocks */ - if (ret != nr) { - /* LCOV_EXCL_START */ + if (ret != nr) return -1; - /* LCOV_EXCL_STOP */ - } for (i = 0; i < nr; ++i) { if (ir[i] != is[i]) { /* LCOV_EXCL_START */ @@ -438,6 +432,12 @@ int raid_selftest(void) /* bad parity */ ir[np / 2 + i] = nd + i; } + for (i = 0; i < np - 1; ++i) { + /* make blocks bad */ + /* we cannot fill them with 0, because the original */ + /* data may be already filled with 0 */ + memset(v[ir[i]], 0x55, size); + } ret = raid_test_scan(np - 1, ir, nd, np, size, v, ref); if (ret != 0) { @@ -447,6 +447,14 @@ int raid_selftest(void) } } + /* scan test with no parity */ + ret = raid_test_scan(0, 0, nd, 0, size, v, ref); + if (ret != -1) { + /* LCOV_EXCL_START */ + goto bail; + /* LCOV_EXCL_STOP */ + } + bail: free(v); free(v_alloc);