]> arthur.barton.de Git - bup.git/commitdiff
Move test.sh save/restore tests to test-save-restore
authorRob Browning <rlb@defaultvalue.org>
Mon, 12 Jun 2017 05:21:23 +0000 (00:21 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 18 Jun 2017 20:05:05 +0000 (15:05 -0500)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Makefile
t/test-save-restore [new file with mode: 0755]
t/test.sh

index 62536f0eb23be70ba8fdb7a8d5358e03ad1df928..5c6ef899964558cf6df6ec88f80f0161c4fe33d8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -148,6 +148,7 @@ runtests-python: all t/tmp
            | tee -a t/tmp/test-log/$$$$.log
 
 cmdline_tests := \
+  t/test-save-restore \
   t/test-packsizelimit \
   t/test-prune-older \
   t/test-web.sh \
diff --git a/t/test-save-restore b/t/test-save-restore
new file mode 100755 (executable)
index 0000000..d1007ab
--- /dev/null
@@ -0,0 +1,141 @@
+#!/usr/bin/env bash
+. wvtest.sh
+. wvtest-bup.sh
+. t/lib.sh
+
+set -o pipefail
+
+top="$(WVPASS pwd)" || exit $?
+tmpdir="$(WVPASS wvmktempdir)" || exit $?
+export BUP_DIR="$tmpdir/bup"
+
+bup() { "$top/bup" "$@"; }
+
+WVPASS cd "$tmpdir"
+
+WVSTART "init"
+
+WVPASS bup init
+
+D=bupdata.tmp
+WVPASS force-delete $D
+WVPASS mkdir $D
+WVPASS touch $D/a
+WVPASS bup random 128k >$D/b
+WVPASS mkdir $D/d $D/d/e
+WVPASS bup random 512 >$D/f
+WVPASS touch $D/d/z
+WVPASS touch $D/d/z
+WVPASS bup index $D
+WVPASS bup save -t $D
+
+WVSTART "restore"
+WVPASS force-delete buprestore.tmp
+WVFAIL bup restore boink
+WVPASS touch "$tmpdir/$D/$D"
+WVPASS bup index -u "$tmpdir/$D"
+WVPASS bup save -n master /
+WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D"
+WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
+WVPASS force-delete buprestore.tmp
+WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D/"
+WVPASS touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
+WVPASS diff -ur $D/ buprestore.tmp/
+WVPASS force-delete buprestore.tmp
+WVPASS echo -n "" | WVPASS bup split -n split_empty_string.tmp
+WVPASS bup restore -C buprestore.tmp split_empty_string.tmp/latest/
+WVPASSEQ "$(cat buprestore.tmp/data)" ""
+
+(
+    tmp=testrestore.tmp
+    WVPASS force-delete $tmp
+    WVPASS mkdir $tmp
+    export BUP_DIR="$(pwd)/$tmp/bup"
+    WVPASS WVPASS bup init
+    WVPASS mkdir -p $tmp/src/x/y/z
+    WVPASS bup random 8k > $tmp/src/x/y/random-1
+    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
+    WVPASS bup index -u $tmp/src
+    WVPASS bup save --strip -n foo $tmp/src
+
+    WVSTART "restore /foo/latest"
+    WVPASS bup restore -C $tmp/restore /foo/latest
+    WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/latest/
+
+    WVSTART "restore /foo/latest/"
+    WVPASS force-delete "$tmp/restore"
+    WVPASS bup restore -C $tmp/restore /foo/latest/
+    for x in $tmp/src/*; do
+        WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
+    done
+
+    WVSTART "restore /foo/latest/."
+    WVPASS force-delete "$tmp/restore"
+    WVPASS bup restore -C $tmp/restore /foo/latest/.
+    WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/
+
+    WVSTART "restore /foo/latest/x"
+    WVPASS force-delete "$tmp/restore"
+    WVPASS bup restore -C $tmp/restore /foo/latest/x
+    WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/x/
+
+    WVSTART "restore /foo/latest/x/"
+    WVPASS force-delete "$tmp/restore"
+    WVPASS bup restore -C $tmp/restore /foo/latest/x/
+    for x in $tmp/src/x/*; do
+        WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
+    done
+
+    WVSTART "restore /foo/latest/x/."
+    WVPASS force-delete "$tmp/restore"
+    WVPASS bup restore -C $tmp/restore /foo/latest/x/.
+    WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/
+) || exit $?
+
+
+WVSTART "save (no index)"
+(
+    tmp=save-no-index.tmp
+    WVPASS force-delete $tmp
+    WVPASS mkdir $tmp
+    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
+    WVPASS bup init
+    WVFAIL bup save -n nothing /
+    WVPASS rm -r "$tmp"
+) || exit $?
+
+WVSTART "save disjoint top-level directories"
+(
+    # Resolve any symlinks involving the top top-level dirs.
+    real_pwd="$(WVPASS resolve-parent .)" || exit $?
+    real_tmp="$(WVPASS resolve-parent /tmp/.)" || exit $?
+    pwd_top="$(echo $real_pwd | WVPASS awk -F "/" '{print $2}')" || exit $?
+    tmp_top="$(echo $real_tmp | WVPASS awk -F "/" '{print $2}')" || exit $?
+
+    if [ "$pwd_top" = "$tmp_top" ]; then
+        echo "(running from within /$tmp_top; skipping test)" 1>&2
+        exit 0
+    fi
+    D=bupdata.tmp
+    WVPASS force-delete $D
+    WVPASS mkdir -p $D/x
+    WVPASS date > $D/x/1
+    tmpdir2="$(WVPASS mktemp -d $real_tmp/bup-test-XXXXXXX)" || exit $?
+    cleanup() { WVPASS rm -r "$tmpdir2"; }
+    WVPASS trap cleanup EXIT
+    WVPASS date > "$tmpdir2/2"
+
+    export BUP_DIR="$tmpdir/bup"
+    WVPASS test -d "$BUP_DIR" && WVPASS rm -r "$BUP_DIR"
+
+    WVPASS bup init
+    WVPASS bup index -vu $(pwd)/$D/x "$tmpdir2"
+    WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir2"
+
+    # For now, assume that "ls -a" and "sort" use the same order.
+    actual="$(WVPASS bup ls -AF src/latest)" || exit $?
+    expected="$(echo -e "$pwd_top/\n$tmp_top/" | WVPASS sort)" || exit $?
+    WVPASSEQ "$actual" "$expected"
+) || exit $?
+
+WVPASS rm -rf "$tmpdir"
index 943ab60458dcd05c9b2507bb20e8ba8c28107626..dc6398c042ab3102f50a4f0b971c67c76a859080 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -14,9 +14,7 @@ bup() { "$top/bup" "$@"; }
 WVPASS cd "$tmpdir"
 
 WVSTART "init"
-
 WVPASS bup init
-
 D=bupdata.tmp
 WVPASS force-delete $D
 WVPASS mkdir $D
@@ -29,6 +27,7 @@ WVPASS touch $D/d/z
 WVPASS bup index $D
 WVPASS bup save -t $D
 
+
 WVSTART "bloom"
 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
 WVPASS rm "$BUP_DIR"/objects/pack/bup.bloom
@@ -39,10 +38,12 @@ WVFAIL bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
 WVPASS bup bloom --force -k 5
 WVPASS bup bloom -c $(ls -1 "$BUP_DIR"/objects/pack/*.idx|head -n1)
 
+
 WVSTART "memtest"
 WVPASS bup memtest -c1 -n100
 WVPASS bup memtest -c1 -n100 --existing
 
+
 WVSTART "save/git-fsck"
 (
     WVPASS cd "$BUP_DIR"
@@ -58,69 +59,6 @@ WVSTART "save/git-fsck"
     WVPASS [ "$n" -eq 0 ]
 ) || exit $?
 
-WVSTART "restore"
-WVPASS force-delete buprestore.tmp
-WVFAIL bup restore boink
-WVPASS touch "$tmpdir/$D/$D"
-WVPASS bup index -u "$tmpdir/$D"
-WVPASS bup save -n master /
-WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D"
-WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
-WVPASS force-delete buprestore.tmp
-WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D/"
-WVPASS touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
-WVPASS diff -ur $D/ buprestore.tmp/
-WVPASS force-delete buprestore.tmp
-WVPASS echo -n "" | WVPASS bup split -n split_empty_string.tmp
-WVPASS bup restore -C buprestore.tmp split_empty_string.tmp/latest/
-WVPASSEQ "$(cat buprestore.tmp/data)" ""
-
-(
-    tmp=testrestore.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(pwd)/$tmp/bup"
-    WVPASS WVPASS bup init
-    WVPASS mkdir -p $tmp/src/x/y/z
-    WVPASS bup random 8k > $tmp/src/x/y/random-1
-    WVPASS bup random 8k > $tmp/src/x/y/z/random-2
-    WVPASS bup index -u $tmp/src
-    WVPASS bup save --strip -n foo $tmp/src
-
-    WVSTART "restore /foo/latest"
-    WVPASS bup restore -C $tmp/restore /foo/latest
-    WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/latest/
-
-    WVSTART "restore /foo/latest/"
-    WVPASS force-delete "$tmp/restore"
-    WVPASS bup restore -C $tmp/restore /foo/latest/
-    for x in $tmp/src/*; do
-        WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
-    done
-
-    WVSTART "restore /foo/latest/."
-    WVPASS force-delete "$tmp/restore"
-    WVPASS bup restore -C $tmp/restore /foo/latest/.
-    WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/
-
-    WVSTART "restore /foo/latest/x"
-    WVPASS force-delete "$tmp/restore"
-    WVPASS bup restore -C $tmp/restore /foo/latest/x
-    WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/x/
-
-    WVSTART "restore /foo/latest/x/"
-    WVPASS force-delete "$tmp/restore"
-    WVPASS bup restore -C $tmp/restore /foo/latest/x/
-    for x in $tmp/src/x/*; do
-        WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
-    done
-
-    WVSTART "restore /foo/latest/x/."
-    WVPASS force-delete "$tmp/restore"
-    WVPASS bup restore -C $tmp/restore /foo/latest/x/.
-    WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/
-) || exit $?
-
 
 WVSTART "ftp"
 WVPASS bup ftp "cat /master/latest/$tmpdir/$D/b" >$D/b.new
@@ -132,6 +70,7 @@ WVPASSEQ "$(sha1sum <$D/f)" "$(sha1sum <$D/f.new)"
 WVPASSEQ "$(cat $D/f.new{,} | sha1sum)" "$(sha1sum <$D/f2.new)"
 WVPASSEQ "$(sha1sum <$D/a)" "$(sha1sum <$D/a.new)"
 
+
 WVSTART "tag"
 WVFAIL bup tag -d v0.n 2>/dev/null
 WVFAIL bup tag v0.n non-existant 2>/dev/null
@@ -145,17 +84,6 @@ WVPASS bup tag -f -d v0.1
 WVFAIL bup tag -d v0.1
 
 
-WVSTART "save (no index)"
-(
-    tmp=save-no-index.tmp
-    WVPASS force-delete $tmp
-    WVPASS mkdir $tmp
-    export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
-    WVPASS bup init
-    WVFAIL bup save -n nothing /
-    WVPASS rm -r "$tmp"
-) || exit $?
-
 WVSTART "indexfile"
 D=indexfile.tmp
 INDEXFILE=tmpindexfile.tmp
@@ -194,38 +122,4 @@ WVPASSEQ "$(bup ls -F buptest/latest/)" "a/
 c/"
 
 
-WVSTART "save disjoint top-level directories"
-(
-    # Resolve any symlinks involving the top top-level dirs.
-    real_pwd="$(WVPASS resolve-parent .)" || exit $?
-    real_tmp="$(WVPASS resolve-parent /tmp/.)" || exit $?
-    pwd_top="$(echo $real_pwd | WVPASS awk -F "/" '{print $2}')" || exit $?
-    tmp_top="$(echo $real_tmp | WVPASS awk -F "/" '{print $2}')" || exit $?
-
-    if [ "$pwd_top" = "$tmp_top" ]; then
-        echo "(running from within /$tmp_top; skipping test)" 1>&2
-        exit 0
-    fi
-    D=bupdata.tmp
-    WVPASS force-delete $D
-    WVPASS mkdir -p $D/x
-    WVPASS date > $D/x/1
-    tmpdir2="$(WVPASS mktemp -d $real_tmp/bup-test-XXXXXXX)" || exit $?
-    cleanup() { WVPASS rm -r "$tmpdir2"; }
-    WVPASS trap cleanup EXIT
-    WVPASS date > "$tmpdir2/2"
-
-    export BUP_DIR="$tmpdir/bup"
-    WVPASS test -d "$BUP_DIR" && WVPASS rm -r "$BUP_DIR"
-
-    WVPASS bup init
-    WVPASS bup index -vu $(pwd)/$D/x "$tmpdir2"
-    WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir2"
-
-    # For now, assume that "ls -a" and "sort" use the same order.
-    actual="$(WVPASS bup ls -AF src/latest)" || exit $?
-    expected="$(echo -e "$pwd_top/\n$tmp_top/" | WVPASS sort)" || exit $?
-    WVPASSEQ "$actual" "$expected"
-) || exit $?
-
 WVPASS rm -rf "$tmpdir"