mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
More coverage test.
This commit is contained in:
parent
cabe782a6f
commit
ba0c979c11
9 changed files with 88 additions and 17 deletions
37
Makefile.am
37
Makefile.am
|
|
@ -113,7 +113,7 @@ maintainer-clean-local:
|
|||
# Automatic testing
|
||||
|
||||
CHECKFLAGS_BASE = --test-skip-device --test-skip-self --test-force-order-alpha
|
||||
CHECKFLAGS_VERBOSE = $(CHECKFLAGS_BASE) -v
|
||||
CHECKFLAGS_VERBOSE = $(CHECKFLAGS_BASE) -v -G
|
||||
CHECKFLAGS = $(CHECKFLAGS_BASE) -q
|
||||
CHECKCOUNT = 1000
|
||||
CHECKSIZE = 4000
|
||||
|
|
@ -139,15 +139,16 @@ check-local:
|
|||
mkdir test/pool
|
||||
echo --- Help
|
||||
$(TESTENV) ./snapraid$(EXEEXT) --test-skip-device -H
|
||||
$(TESTENV) ./snapraid$(EXEEXT) --test-skip-device -V
|
||||
$(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
|
||||
$(TESTENV) ./snapraid$(EXEEXT) --test-skip-device -T
|
||||
echo --- Some commands with empty array
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(CONF) diff
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(CONF) dup
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(CONF) list > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) diff
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) dup
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) list > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-force-murmur3 sync
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status -l ">&1"
|
||||
|
|
@ -163,12 +164,11 @@ endif
|
|||
$(TESTENV) ./mktest$(EXEEXT) generate 1 6 $(CHECKCOUNT) $(CHECKSIZE)
|
||||
echo DUP > test/disk1/DUP1
|
||||
echo DUP > test/disk1/DUP2
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(CONF) diff > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(CONF) diff -G > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) diff > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-force-order-physical sync
|
||||
echo --- Some commands with a not empty array
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(CONF) dup -l test.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(CONF) list -l test.log > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) dup -l test.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) list -l test.log > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status -l test.log
|
||||
if HAVE_SYMLINK
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) pool
|
||||
|
|
@ -178,10 +178,21 @@ endif
|
|||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -a check
|
||||
echo --- Check the --gen-conf command
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --gen-conf test/content
|
||||
echo --- Filter
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -d disk1 check
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) -f "*a" -f "a/" -f "/b/a*" check
|
||||
echo --- Delete some files and sync
|
||||
rm test/disk4/a/9*
|
||||
rm test/disk5/a/9*
|
||||
rm test/disk6/a/9*
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) diff > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
|
||||
echo --- Move some files, sync and check
|
||||
mv test/disk1/a/9* test/disk4/a
|
||||
mv test/disk2/a/9* test/disk5/a
|
||||
mv test/disk3/a/9* test/disk6/a
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(CONF) diff > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
|
||||
echo --- Create some more files, hardlinks and empty directories, delete others, sync PAR1 and check
|
||||
|
|
@ -203,13 +214,13 @@ endif
|
|||
echo 3 > test/disk3/file_hardlink1
|
||||
ln test/disk3/file_hardlink1 test/disk3/file_hardlink2
|
||||
ln test/disk3/file_hardlink1 test/disk3/file_hardlink3
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(PAR1) diff > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(PAR1) diff > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-fallocate -c $(PAR1) --test-force-order-inode sync
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-sequential -c $(PAR1) check
|
||||
echo --- Some commands with a not empty array
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(PAR1) dup
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(PAR1) list > output.log
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(PAR1) dup
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_VERBOSE) -c $(PAR1) list > output.log
|
||||
if HAVE_SYMLINK
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) pool
|
||||
endif
|
||||
|
|
@ -261,6 +272,10 @@ endif
|
|||
mv test/disk2.old test/disk2
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
|
||||
echo --- Corrupt the content file
|
||||
$(TESTENV) ./mktest$(EXEEXT) write 1 100 100 test/content
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-failure -c $(CONF) sync
|
||||
rm test/content
|
||||
echo --- Delete some files, create some new, sync and check
|
||||
rm test/disk1/a/1*
|
||||
rm test/disk2/a/2*
|
||||
|
|
|
|||
4
check.c
4
check.c
|
|
@ -164,11 +164,13 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
int id[LEV_MAX];
|
||||
int ip[LEV_MAX];
|
||||
|
||||
/* no fix required */
|
||||
/* no fix required, already checked at higher level, but just to be sure */
|
||||
if (failed_count == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
/* recompute only the parity */
|
||||
raid_gen(diskmax, state->level, state->block_size, buffer);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
n = state->level;
|
||||
|
|
|
|||
4
elem.c
4
elem.c
|
|
@ -85,8 +85,10 @@ struct snapraid_filter* filter_alloc_file(int direction, const char* pattern)
|
|||
|
||||
/* a slash must be the first char, as we reject PATH/DIR/FILE */
|
||||
if (filter->pattern[0] != '/') {
|
||||
/* LCOV_EXCL_START */
|
||||
free(filter);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,8 +110,10 @@ struct snapraid_filter* filter_alloc_disk(int direction, const char* pattern)
|
|||
|
||||
/* no slash allowed in disk names */
|
||||
if (strchr(filter->pattern, '/') != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
free(filter);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
return filter;
|
||||
|
|
|
|||
6
mingw.c
6
mingw.c
|
|
@ -21,6 +21,12 @@
|
|||
|
||||
#ifdef __MINGW32__ /* Only for MingW */
|
||||
|
||||
/**
|
||||
* Standard exit codes.
|
||||
*/
|
||||
int exit_success = 0;
|
||||
int exit_failure = 1;
|
||||
|
||||
/* Adds missing Windows declaration */
|
||||
typedef struct _FILE_ATTRIBUTE_TAG_INFO {
|
||||
DWORD FileAttributes;
|
||||
|
|
|
|||
10
portable.h
10
portable.h
|
|
@ -251,5 +251,15 @@ void os_done(void);
|
|||
*/
|
||||
FILE* stdlog;
|
||||
|
||||
/**
|
||||
* Exit codes for testing.
|
||||
*/
|
||||
int exit_success;
|
||||
int exit_failure;
|
||||
#undef EXIT_SUCCESS
|
||||
#undef EXIT_FAILURE
|
||||
#define EXIT_SUCCESS exit_success
|
||||
#define EXIT_FAILURE exit_failure
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
30
snapraid.c
30
snapraid.c
|
|
@ -104,8 +104,10 @@ void log_open(const char* log)
|
|||
strftime(text_T, sizeof(text_T), "%H%M%S", tm);
|
||||
strftime(text_D, sizeof(text_T), "%Y%m%d", tm);
|
||||
} else {
|
||||
/* LCOV_EXCL_START */
|
||||
strcpy(text_T, "invalid");
|
||||
strcpy(text_D, "invalid");
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* file mode */
|
||||
|
|
@ -227,6 +229,7 @@ void config(char* conf, size_t conf_size, const char* argv0)
|
|||
#define OPT_TEST_FORCE_CONTENT_TEXT 274
|
||||
#define OPT_TEST_SKIP_CONTENT_CHECK 275
|
||||
#define OPT_TEST_SKIP_PARITY_ACCESS 276
|
||||
#define OPT_TEST_EXPECT_FAILURE 277
|
||||
|
||||
#if HAVE_GETOPT_LONG
|
||||
struct option long_options[] = {
|
||||
|
|
@ -315,6 +318,9 @@ struct option long_options[] = {
|
|||
/* Skip the parity access */
|
||||
{ "test-skip-parity-access", 0, 0, OPT_TEST_SKIP_PARITY_ACCESS },
|
||||
|
||||
/* Exit generic failure */
|
||||
{ "test-expect-failure", 0, 0, OPT_TEST_EXPECT_FAILURE },
|
||||
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
#endif
|
||||
|
|
@ -497,8 +503,10 @@ int main(int argc, char* argv[])
|
|||
opt.force_device = 1;
|
||||
break;
|
||||
case 'N' :
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "WARNING! Option --find-by-name, -N is deprecated and does nothing!\n");
|
||||
break;
|
||||
/* LCOV_EXCL_STOP */
|
||||
case 'a' :
|
||||
opt.auditonly = 1;
|
||||
break;
|
||||
|
|
@ -590,6 +598,11 @@ int main(int argc, char* argv[])
|
|||
case OPT_TEST_FORCE_CONTENT_TEXT :
|
||||
opt.force_content_text = 1;
|
||||
break;
|
||||
case OPT_TEST_EXPECT_FAILURE :
|
||||
/* invert the exit code */
|
||||
exit_success = 1;
|
||||
exit_failure = 0;
|
||||
break;
|
||||
default:
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Unknown option '%c'\n", (char)c);
|
||||
|
|
@ -605,8 +618,10 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
if (optind + 1 != argc) {
|
||||
/* LCOV_EXCL_START */
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
command = argv[optind];
|
||||
|
|
@ -821,8 +836,11 @@ int main(int argc, char* argv[])
|
|||
state_write(&state);
|
||||
|
||||
/* abort if required */
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
} else if (operation == OPERATION_DRY) {
|
||||
state_read(&state);
|
||||
|
||||
|
|
@ -861,8 +879,11 @@ int main(int argc, char* argv[])
|
|||
state_write(&state);
|
||||
|
||||
/* abort if required */
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
} else if (operation == OPERATION_REWRITE) {
|
||||
state_read(&state);
|
||||
|
||||
|
|
@ -908,8 +929,11 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
/* abort if required */
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
/* close log file */
|
||||
|
|
|
|||
6
state.c
6
state.c
|
|
@ -2558,11 +2558,9 @@ static void decoding_error(const char* path, STREAM* f)
|
|||
crc_stored = crc32c(crc_stored, buf, 4);
|
||||
|
||||
if (crc_computed != crc_stored) {
|
||||
/* LCOV_EXCL_START */
|
||||
fprintf(stderr, "Mismatching CRC in '%s'\n", path);
|
||||
fprintf(stderr, "This content file is damaged! Use an alternate copy.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
} else {
|
||||
fprintf(stderr, "The file CRC is correct!\n");
|
||||
}
|
||||
|
|
@ -4164,10 +4162,12 @@ int state_progress_begin(struct snapraid_state* state, block_off_t blockstart, b
|
|||
|
||||
/* stop if requested */
|
||||
if (global_interrupt) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (!state->opt.gui) {
|
||||
printf("Not starting for interruption\n");
|
||||
}
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
@ -4260,11 +4260,13 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
|
|||
|
||||
/* stop if requested */
|
||||
if (global_interrupt) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (!state->opt.gui) {
|
||||
printf("\n");
|
||||
printf("Stopping for interruption at block %u\n", blockpos);
|
||||
}
|
||||
return 1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# Test configuration file
|
||||
blocksize 1
|
||||
parity test/parity
|
||||
content test/content
|
||||
|
|
@ -12,4 +13,5 @@ include *.hidden
|
|||
exclude *.unrecoverable
|
||||
pool test/pool
|
||||
share \\server\jbod
|
||||
autosave 1
|
||||
|
||||
|
|
|
|||
6
unix.c
6
unix.c
|
|
@ -19,6 +19,12 @@
|
|||
|
||||
#ifndef __MINGW32__ /* Only for Unix */
|
||||
|
||||
/**
|
||||
* Standard exit codes.
|
||||
*/
|
||||
int exit_success = 0;
|
||||
int exit_failure = 1;
|
||||
|
||||
int open_noatime(const char* file, int flags)
|
||||
{
|
||||
#ifdef O_NOATIME
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue