From 3b6dfd9ffecb883c4d1a0f2edb5ec8a8720cb35a Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 16 Sep 2013 18:52:10 +0200 Subject: [PATCH] Fixes the -G option and adds test for it. --- Makefile.am | 2 ++ dup.c | 2 +- snapraid.c | 30 +++++++++++++++--------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Makefile.am b/Makefile.am index 9153c6d8..cd34c2ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -116,7 +116,9 @@ endif echo --- Create some files, sync raid6 and check $(TESTENV) ./mktest$(EXEEXT) generate 1 3 $(CHECKCOUNT) $(CHECKSIZE) $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf diff > test.log + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf diff -G > test.log $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf dup + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf dup -G $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid6.conf --test-force-order-physical sync $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid6.conf status if HAVE_SYMLINK diff --git a/dup.c b/dup.c index 19425bfd..d7d6adc5 100644 --- a/dup.c +++ b/dup.c @@ -95,7 +95,7 @@ void state_dup(struct snapraid_state* state) count = 0; size = 0; - + /* for each disk */ for(i=state->disklist;i!=0;i=i->next) { tommy_node* j; diff --git a/snapraid.c b/snapraid.c index 6d21be4f..fccea839 100644 --- a/snapraid.c +++ b/snapraid.c @@ -508,6 +508,21 @@ int main(int argc, char* argv[]) raid_init(); crc32c_init(); + /* open the log file */ + if (log == 0) + log = "2"; + if (strcmp(log, "1") == 0) { + stdlog = stdout; + } else if (strcmp(log, "2") == 0) { + stdlog = stderr; + } else { + stdlog = fopen(log, "wt"); + if (!stdlog) { + fprintf(stderr, "Error opening the log file '%s'. %s.\n", log, strerror(errno)); + exit(EXIT_FAILURE); + } + } + if (!opt.skip_self) selftest(opt.gui); @@ -534,21 +549,6 @@ int main(int argc, char* argv[]) (void)lock; #endif - /* open the log file */ - if (log == 0) - log = "2"; - if (strcmp(log, "1") == 0) { - stdlog = stdout; - } else if (strcmp(log, "2") == 0) { - stdlog = stderr; - } else { - stdlog = fopen(log, "wt"); - if (!stdlog) { - fprintf(stderr, "Error opening the log file '%s'. %s.\n", log, strerror(errno)); - exit(EXIT_FAILURE); - } - } - if (operation == OPERATION_DIFF) { state_read(&state);