diff --git a/Makefile.am b/Makefile.am index 4a29bd32..81f4cfc6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -133,7 +133,7 @@ maintainer-clean-local: # --test-force-order-alpha # Ensures to process files always in the same order despites # the inode, physical location, and dir order assigned by the OS. -CHECKFLAGS_BASE = --test-skip-device --test-skip-self --test-force-order-alpha +CHECKFLAGS_BASE = --test-skip-device --test-skip-self --test-force-order-alpha --test-force-progress # Verbose options CHECKFLAGS_VERBOSE = $(CHECKFLAGS_BASE) -v -G diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 038c8bbc..1ad1c222 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -236,6 +236,7 @@ void config(char* conf, size_t conf_size, const char* argv0) #define OPT_TEST_RUN 278 #define OPT_TEST_FORCE_SCAN_WINFIND 279 #define OPT_TEST_IMPORT_CONTENT 280 +#define OPT_TEST_FORCE_PROGRESS 281 #if HAVE_GETOPT_LONG struct option long_options[] = { @@ -337,6 +338,9 @@ struct option long_options[] = { /* Alternative import working by data */ { "test-import-content", 1, 0, OPT_TEST_IMPORT_CONTENT }, + /* Force immediate progress state update */ + { "test-force-progress", 0, 0, OPT_TEST_FORCE_PROGRESS }, + { 0, 0, 0, 0 } }; #endif @@ -644,6 +648,9 @@ int main(int argc, char* argv[]) case OPT_TEST_FORCE_SCAN_WINFIND : opt.force_scan_winfind = 1; break; + case OPT_TEST_FORCE_PROGRESS : + opt.force_progress = 1; + break; default : /* LCOV_EXCL_START */ fprintf(stderr, "Unknown option '%c'\n", (char)c); diff --git a/cmdline/state.c b/cmdline/state.c index 212756ba..6dad39ea 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -4329,7 +4329,9 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off pred -= PROGRESS_MAX; /* if the previous measure is different */ - if (state->progress_tick == 0 || state->progress_time[pred] != now) { + if (state->progress_tick == 0 + || state->progress_time[pred] != now + ) { uint64_t tick_total; uint64_t tick_cpu; unsigned out_perc = 0; @@ -4345,7 +4347,10 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off out_perc = countpos * 100 / countmax; /* if we have at least 5 measures */ - if (state->progress_tick >= 5) { + if (state->progress_tick >= 5 + /* or if we are running in test mode, with at least one measure */ + || (state->opt.force_progress && state->progress_tick >= 1) + ) { int oldest; int past; time_t delta_time; diff --git a/cmdline/state.h b/cmdline/state.h index 8c26a43a..a8638b51 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -91,6 +91,7 @@ struct snapraid_option { int force_content_write; /**< Force the update of the content file. */ int force_content_text; /**< Force the use of text version of content file. */ int force_scan_winfind; /**< Force the use of FindFirst/Next in Windows to list directories. */ + int force_progress; /**< Force the use of the progress status. */ }; /**