]> arthur.barton.de Git - bup.git/blobdiff - t/test.sh
Explicitly use "du -k" to set block size in t/test.sh.
[bup.git] / t / test.sh
index 7186710c2ea6d6c38c8aa6b0e2624d5215f581ac..4d65f26d3484df59cdfffd1620373412022640ba 100755 (executable)
--- a/t/test.sh
+++ b/t/test.sh
@@ -30,6 +30,7 @@ touch $D/a
 WVPASS bup random 128k >$D/b
 mkdir $D/d $D/d/e
 WVPASS bup random 512 >$D/f
+WVPASS ln -s non-existent-file $D/g
 WVPASSEQ "$(bup index -s $D/)" "A $D/"
 WVPASSEQ "$(bup index -s $D/b)" ""
 WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
@@ -40,7 +41,8 @@ A $D/b"
 touch $D/d/z
 bup tick
 WVPASSEQ "$(bup index --check -usx $D)" \
-"A $D/f
+"A $D/g
+A $D/f
 A $D/d/z
 A $D/d/e/
 A $D/d/
@@ -58,7 +60,8 @@ WVPASSEQ "$(bup index --check -us $D/d --fake-valid)" \
 touch $D/d/z
 WVPASS bup index -u $D/d/z  # becomes modified
 WVPASSEQ "$(bup index -s $D/a $D $D/b)" \
-"A $D/f
+"A $D/g
+A $D/f
 M $D/d/z
   $D/d/e/
 M $D/d/
@@ -68,14 +71,16 @@ A $D/"
 
 WVPASS bup index -u $D/d/e $D/a --fake-invalid
 WVPASSEQ "$(cd $D && bup index -m .)" \
-"./f
+"./g
+./f
 ./d/z
 ./d/e/
 ./d/
 ./a
 ./"
 WVPASSEQ "$(cd $D && bup index -m)" \
-"f
+"g
+f
 d/z
 d/e/
 d/
@@ -89,8 +94,8 @@ mv $BUP_DIR/bupindex $BUP_DIR/bi.old
 WVFAIL bup save -t $D/d/e/fifotest
 mkfifo $D/d/e/fifotest
 WVPASS bup index -u $D/d/e/fifotest
-WVFAIL bup save -t $D/d/e/fifotest
-WVFAIL bup save -t $D/d/e
+WVPASS bup save -t $D/d/e/fifotest
+WVPASS bup save -t $D/d/e
 rm -f $D/d/e/fifotest
 WVPASS bup index -u $D/d/e
 WVFAIL bup save -t $D/d/e/fifotest
@@ -99,22 +104,28 @@ mv $BUP_DIR/bi.old $BUP_DIR/bupindex
 WVPASS bup index -u $D/d/e
 WVPASS bup save -t $D/d/e
 WVPASSEQ "$(cd $D && bup index -m)" \
-"f
+"g
+f
 d/z
 d/
 a
 ./"
 WVPASS bup save -t $D/d
+WVPASS bup index --fake-invalid $D/d/z
+WVPASS bup save -t $D/d/z
+WVPASS bup save -t $D/d/z  # test regenerating trees when no files are changed
+WVPASS bup save -t $D/d
 WVPASSEQ "$(cd $D && bup index -m)" \
-"f
+"g
+f
 a
 ./"
-tree1=$(bup save -t $D)
+tree1=$(bup save -t $D) || WVFAIL
 WVPASSEQ "$(cd $D && bup index -m)" ""
-tree2=$(bup save -t $D)
+tree2=$(bup save -t $D) || WVFAIL
 WVPASSEQ "$tree1" "$tree2"
 WVPASSEQ "$(bup index -s / | grep ^D)" ""
-tree3=$(bup save -t /)
+tree3=$(bup save -t /) || WVFAIL
 WVPASSEQ "$tree1" "$tree3"
 WVPASS bup save -r :$BUP_DIR -n r-test $D
 WVFAIL bup save -r :$BUP_DIR/fake/path -n r-test $D
@@ -208,7 +219,7 @@ WVSTART "save/git-fsck"
     #git prune
     (cd "$TOP/t/sampledata" && WVPASS bup save -vvn master /) || WVFAIL
     n=$(git fsck --full --strict 2>&1 | 
-      egrep -v 'dangling (commit|tree)' |
+      egrep -v 'dangling (commit|tree|blob)' |
       tee -a /dev/stderr | 
       wc -l)
     WVPASS [ "$n" -eq 0 ]
@@ -217,10 +228,14 @@ WVSTART "save/git-fsck"
 WVSTART "restore"
 rm -rf buprestore.tmp
 WVFAIL bup restore boink
+touch $TOP/$D/$D
+bup index -u $TOP/$D
+bup save -n master /
 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D"
 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
 rm -rf buprestore.tmp
 WVPASS bup restore -C buprestore.tmp "/master/latest/$TOP/$D/"
+touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
 WVPASS diff -ur $D/ buprestore.tmp/
 
 WVSTART "ftp"
@@ -283,7 +298,7 @@ mkdir $D/d $D/d/e
 WVPASS bup random 512 >$D/f
 WVPASS bup index -ux $D
 bup save -n exclude-bupdir $D
-WVPASSEQ "$(bup ls exclude-bupdir/latest/$TOP/$D/)" "a
+WVPASSEQ "$(bup ls -a exclude-bupdir/latest/$TOP/$D/)" "a
 b
 d/
 f"
@@ -377,6 +392,8 @@ WVPASS bup random 128k >$D/b
 mkdir $D/d $D/d/e
 WVPASS bup random 512 >$D/f
 WVPASS bup index -ux $D
+WVFAIL bup save --graft =/grafted -n graft-point-absolute $D
+WVFAIL bup save --graft $TOP/$D= -n graft-point-absolute $D
 bup save --graft $TOP/$D=/grafted -n graft-point-absolute $D
 WVPASSEQ "$(bup ls graft-point-absolute/latest/grafted/)" "a
 b
@@ -424,3 +441,76 @@ WVPASS true
 WVPASS bup import-rsnapshot $D/
 WVPASSEQ "$(bup ls buptest/latest/)" "a/
 c/"
+
+
+if [ "$(which rdiff-backup)" != "" ]; then
+    WVSTART "import-rdiff-backup"
+    D=rdiff-backup.tmp
+    export BUP_DIR="$TOP/$D/.bup"
+    rm -rf $D
+    mkdir $D
+    WVPASS bup init
+    mkdir $D/rdiff-backup
+    rdiff-backup $TOP/cmd $D/rdiff-backup
+    bup tick
+    rdiff-backup $TOP/Documentation $D/rdiff-backup
+    WVPASS bup import-rdiff-backup $D/rdiff-backup import-rdiff-backup
+    WVPASSEQ "$(bup ls import-rdiff-backup/ | wc -l)" "3"
+    WVPASSEQ "$(bup ls import-rdiff-backup/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
+fi
+
+
+WVSTART "compression"
+D=compression0.tmp
+export BUP_DIR="$TOP/$D/.bup"
+rm -rf $D
+mkdir $D
+WVPASS bup init
+WVPASS bup index $TOP/Documentation
+WVPASS bup save -n compression -0 --strip $TOP/Documentation
+# 'ls' on NetBSD sets -A by default when running as root, so we have to undo
+# it by grepping out any dotfiles.  (Normal OSes don't auto-set -A, but this
+# is harmless there.)
+WVPASSEQ "$(bup ls compression/latest/ | sort)" \
+        "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
+COMPRESSION_0_SIZE=$(du -k -s $D | cut -f1)
+
+D=compression9.tmp
+export BUP_DIR="$TOP/$D/.bup"
+rm -rf $D
+mkdir $D
+WVPASS bup init
+WVPASS bup index $TOP/Documentation
+WVPASS bup save -n compression -9 --strip $TOP/Documentation
+WVPASSEQ "$(bup ls compression/latest/ | sort)" "$(ls $TOP/Documentation | sort)"
+COMPRESSION_9_SIZE=$(du -k -s $D | cut -f1)
+
+WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
+
+
+WVSTART "save disjoint top-level directories"
+(
+    set -e
+    top_dir="$(echo $(pwd) | awk -F "/" '{print $2}')"
+    if [ "$top_dir" == tmp ]; then
+        echo "(running from within /tmp; skipping test)"
+        exit 0
+    fi
+    D=bupdata.tmp
+    rm -rf $D
+    mkdir -p $D/x
+    date > $D/x/1
+    tmpdir="$(mktemp --tmpdir=/tmp -d bup-test-XXXXXXX)"
+    cleanup() { set -x; rm -rf "${tmpdir}"; set +x; }
+    trap cleanup EXIT
+    date > "$tmpdir/2"
+
+    export BUP_DIR="$TOP/buptest.tmp"
+    rm -rf "$BUP_DIR"
+
+    WVPASS bup init
+    WVPASS bup index -vu $(pwd)/$D/x "$tmpdir"
+    WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir"
+    # For now, assume that "ls -a" and "sort" use the same order.
+    WVPASSEQ "$(bup ls -a src/latest)" "$(echo -e "$top_dir/\ntmp/" | sort)"
+) || WVFAIL