diff --git a/Makefile.am b/Makefile.am index 944ec2f1..1c78caa0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -112,7 +112,9 @@ maintainer-clean-local: # Automatic testing -CHECKFLAGS = --test-skip-device --test-skip-self --test-force-order-alpha -q +CHECKFLAGS_BASE = --test-skip-device --test-skip-self --test-force-order-alpha +CHECKFLAGS_VERBOSE = $(CHECKFLAGS_BASE) -v +CHECKFLAGS = $(CHECKFLAGS_BASE) -q CHECKCOUNT = 1000 CHECKSIZE = 4000 CONF = $(srcdir)/test-par6.conf @@ -137,6 +139,7 @@ check-local: mkdir test/pool echo --- Help $(TESTENV) ./snapraid$(EXEEXT) --test-skip-device -h + $(TESTENV) ./mktest$(EXEEXT) echo --- Run the self test only this time $(TESTENV) ./snapraid$(EXEEXT) --test-skip-device -c $(CONF) status echo --- Run the speed test @@ -372,11 +375,10 @@ endif $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-force-scrub-even scrub $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check - echo --- Delete files from three disks and fix with import in PAR2 + echo --- Delete files from three disks and check/fix with import in PAR2 rm -r test/disk1/a rm -r test/disk2/a mv test/disk3/a test/a - $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR2) fix -l test.log $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -i test/a -c $(PAR2) fix -l test.log rm -r test/a $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync @@ -521,11 +523,12 @@ endif $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR1) check -l test.log $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) fix -l test.log $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check - echo --- Corrupt some files, fix and check with PAR2 + echo --- Corrupt some files, fix and check with PAR2 in verbose mode $(TESTENV) ./mktest$(EXEEXT) change 4 500 test/disk2/b/* $(TESTENV) ./mktest$(EXEEXT) change 4 500 test/disk3/b/* + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) --test-expect-unrecoverable -c $(PAR1) check -l test.log > /dev/null + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) --test-expect-unrecoverable -c $(PAR1) fix -l test.log > /dev/null $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) -a check -l test.log - $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR1) check -l test.log $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) check -l test.log $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check diff --git a/maketest.sh b/maketest.sh index a0c74db4..a4eee659 100755 --- a/maketest.sh +++ b/maketest.sh @@ -3,8 +3,6 @@ make distclean -rm -rf cov_release - if ! ./configure --enable-coverage; then exit 1 fi @@ -13,6 +11,7 @@ if ! make lcov_reset check lcov_capture lcov_html; then exit 1 fi +rm -rf cov_release mv cov cov_release if ! make distclean; then diff --git a/mktest.c b/mktest.c index 52ff7d12..89f3afeb 100644 --- a/mktest.c +++ b/mktest.c @@ -222,18 +222,6 @@ void fallback(int f, struct stat* st) } } -void duplicate_name(const char* path, char* newpath) -{ - size_t len; - - strcpy(newpath, path); - - len = strlen(newpath); - - newpath[len] = 'a' + rnd('z' - 'a'); - newpath[len+1] = 0; -} - void writ(const char* path, int size, int silent_error) { struct stat st; @@ -472,10 +460,8 @@ int main(int argc, char* argv[]) int i, j, b; if (argc < 2) { - /* LCOV_EXCL_START */ help(); - exit(EXIT_FAILURE); - /* LCOV_EXCL_STOP */ + exit(EXIT_SUCCESS); } if (strcmp(argv[1], "generate") == 0) { diff --git a/scrub.c b/scrub.c index 19c5b2b3..ff3fa8fa 100644 --- a/scrub.c +++ b/scrub.c @@ -263,6 +263,8 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par /* report that the block and the file are not synched */ block_is_unsynched = 1; file_is_unsynched = 1; + + /* follow */ } /* note that we intentionally don't abort if the file has different attributes */ @@ -330,6 +332,8 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par fprintf(stdlog, "parity_error:%u:%s: Read error\n", i, lev_config_name(l)); ++error; error_on_this_block = 1; + + /* follow */ } } diff --git a/selftest.c b/selftest.c index 4b79bbb5..708d084e 100644 --- a/selftest.c +++ b/selftest.c @@ -27,6 +27,10 @@ #include "elem.h" #include "state.h" #include "tommyhash.h" +#include "tommyarray.h" +#include "tommyarrayblk.h" +#include "tommyarrayblkof.h" +#include "tommyhashdyn.h" struct hash32_test_vector { const char* data; @@ -68,6 +72,7 @@ static struct hash32_test_vector TEST_HASH32[] = { { "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0xa1f368d8 }, { "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x805fc63d }, { "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0x7f75dd0f }, +{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0xb9154382 }, { 0, 0, 0 } }; @@ -93,6 +98,7 @@ static struct hash64_test_vector TEST_HASH64[] = { { "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0x5afe09e8214e2163ULL }, { "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x115b6276d209fab6ULL }, { "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0xd0636d2f01cf3a3eULL }, +{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0x6d259f5fef74f93eULL }, { 0, 0, 0 } }; @@ -246,6 +252,91 @@ static void test_crc32c(void) } } +/** + * Size of tommy data structures. + */ +#define TOMMY_SIZE 256 + +static int tommy_test_search(const void* arg, const void* obj) +{ + return arg != obj; +} + +static void test_tommy(void) +{ + tommy_array array; + tommy_arrayblk arrayblk; + tommy_arrayblkof arrayblkof; + tommy_hashdyn hashdyn; + tommy_hashdyn_node node[TOMMY_SIZE]; + unsigned i; + + tommy_array_init(&array); + tommy_arrayblk_init(&arrayblk); + tommy_arrayblkof_init(&arrayblkof, sizeof(unsigned)); + + for(i=0;iname, file->sub); fprintf(stderr, "No access at file '%s'.\n", handle[j].path); fprintf(stderr, "WARNING! Please fix the access permission in the data disk.\n"); @@ -566,14 +567,14 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari /* this isn't a serious error, so we skip this block, and continue with others */ error_on_this_block = 1; continue; - } else { - fprintf(stdlog, "error:%u:%s:%s: Open error. %s\n", i, handle[j].disk->name, file->sub, strerror(errno)); - fprintf(stderr, "DANGER! Unexpected open error in a data disk, it isn't possible to sync.\n"); - fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", handle[j].disk->dir, handle[j].path); - printf("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub); } - + /* LCOV_EXCL_START */ + fprintf(stdlog, "error:%u:%s:%s: Open error. %s\n", i, handle[j].disk->name, file->sub, strerror(errno)); + fprintf(stderr, "DANGER! Unexpected open error in a data disk, it isn't possible to sync.\n"); + fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", handle[j].disk->dir, handle[j].path); + printf("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", file->sub); + ++error; goto bail; /* LCOV_EXCL_STOP */