From a66ccb5cc1566e0c95c614ab71ca9ce8c0ccf763 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 1 Dec 2015 23:44:06 +0100 Subject: [PATCH] Some more regression tests for move/copy/invalidate --- Makefile.am | 23 +++++++++++++++++++++++ cmdline/snapraid.c | 8 ++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 34e43cb9..78a968ec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -282,6 +282,29 @@ endif $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync -l ">&1" rm -r bench/disk1/TEST* $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -E sync +# Now create, duplicate, move and partial sync + head -c 8192 /dev/zero > bench/disk1/INVA1 + head -c 8192 /dev/zero > bench/disk1/INVA2 + head -c 8192 /dev/zero > bench/disk1/INVA3 + head -c 8192 /dev/zero > bench/disk1/MOVE1 + cp -a bench/disk1/MOVE1 bench/disk1/MOVE2 + cp -a bench/disk1/MOVE1 bench/disk1/MOVE3 + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync + mv bench/disk1/MOVE2 bench/disk2/MOVE2 + mv bench/disk1/MOVE3 bench/disk3/MOVE3 + head -c 8192 /dev/zero > bench/disk4/MOVE4 + cp -a bench/disk1/INVA1 bench/disk1/EXTRA1 + cp -a bench/disk1/INVA2 bench/disk1/EXTRA2 + cp -a bench/disk1/INVA3 bench/disk1/EXTRA3 + rm bench/disk1/INVA1 + touch bench/disk1/INVA2 + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-kill-after-sync sync + mv bench/disk2/MOVE2 bench/disk4/MOVE4 + mv bench/disk3/MOVE3 bench/disk5/MOVE5 + mv bench/disk4/MOVE4 bench/disk6/MOVE6 + rm bench/disk1/EXTRA1 + touch bench/disk1/EXTRA2 + $(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -E sync #### NOT EMPTY #### echo --- Create some files $(TESTENV) ./mktest$(EXEEXT) generate 1 6 $(CHECKCOUNT) $(CHECKSIZE) diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index fc6fa5ce..7c2bcceb 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -1133,8 +1133,12 @@ int main(int argc, char* argv[]) ret = state_sync(&state, blockstart, blockcount); /* save the new state if required */ - if (!opt.kill_after_sync && (state.need_write || state.opt.force_content_write)) - state_write(&state); + if (!opt.kill_after_sync) { + if ((state.need_write || state.opt.force_content_write)) + state_write(&state); + } else { + log_fatal("WARNING! Skipped state write for --test-kill-after-sync option.\n"); + } /* abort if required */ if (ret != 0) {