From 6897c0ae70892e40fd7603e4d00662038c01a82d Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 4 Oct 2021 20:37:50 +0200 Subject: add checks for consistency It works ok, but man, git is good --- exp/Makefile | 11 ++++++----- exp/exp.sh | 30 ++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) (limited to 'exp') diff --git a/exp/Makefile b/exp/Makefile index a5b4864..aaf377c 100644 --- a/exp/Makefile +++ b/exp/Makefile @@ -1,6 +1,7 @@ REPO_URL := https://club1.fr/~nicolas/git/dna-backup/ -export MAX_VERSION ?= 3 +export DNA_BACKUP ?= ../dna-backup +export MAX_VERSION ?= 5 export COMMITS ?= commits export BACKUP ?= backup export DIFFS ?= diffs @@ -47,7 +48,7 @@ results: backup run | sort -k2 \ > $@ -run: $(COMMITS) ../dna-backup | $(DATADIRS) +run: $(COMMITS) $(DNA_BACKUP) | $(DATADIRS) rm -rf $(DATADIRS:%=%/*) ./exp.sh touch $@ @@ -55,8 +56,8 @@ run: $(COMMITS) ../dna-backup | $(DATADIRS) backup diffs: mkdir $@ -../dna-backup: .FORCE - @$(MAKE) -C .. --no-print-directory dna-backup +$(DNA_BACKUP): .FORCE + @$(MAKE) -C $(@D) --no-print-directory $(@F) $(COMMITS): | repo git $(GITC) log --reverse --no-merges --pretty=tformat:"%H %as" \ @@ -74,7 +75,7 @@ clean: mostlyclean rm -f $(COMMITS) mostlyclean: resultsclean - rm -rf $(DATADIRS) versions + rm -rf $(DATADIRS) versions run resultsclean: rm -f results summary.csv $(SIZEFILES) diff --git a/exp/exp.sh b/exp/exp.sh index 9edf367..59a5ef1 100755 --- a/exp/exp.sh +++ b/exp/exp.sh @@ -1,6 +1,7 @@ #!/bin/bash # This script expects the following variables to be exported: +# - DNA_BACKUP: the path to dna-backup binary # - REPO_PATH: the path of the repo the experiment is based on # - MAX_VERSION: the max number for versions for the experiment # - COMMITS: the name of the file that contains the lists of versions @@ -20,10 +21,35 @@ do $GITC checkout $hash # create diff for this version - $GITC diff --minimal --binary --unified=0 $prev | gzip > $DIFFS/$i.diff.gz + $GITC diff --minimal --binary --unified=0 $prev \ + | gzip \ + > "$DIFFS/$i.diff.gz" # create backup for this version - ../dna-backup commit -v 2 $REPO_PATH $BACKUP + $DNA_BACKUP commit -v 2 $REPO_PATH $BACKUP + + if [[ $(( $i % 4 )) == 0 ]] + then + # check diff correctness + TEMP=$(mktemp -d) + for n in $(seq 0 $i) + do + cat "$DIFFS/$n.diff.gz" \ + | gzip --decompress \ + | git -C $TEMP apply --binary --unidiff-zero --whitespace=nowarn - \ + || echo "Git patchs do not match source" + done + cp $REPO_PATH/.git $TEMP/ + diff --brief --recursive $REPO_PATH $TEMP \ + || echo "dna-backup restore do not match source" + rm -rf $TEMP + + # check backup correctness + TEMP=$(mktemp -d) + $DNA_BACKUP restore -v 2 $BACKUP $TEMP + diff --brief --recursive $REPO_PATH $TEMP + rm -rf $TEMP + fi prev=$hash let i++ -- cgit v1.2.3