]> 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 4920308c805287e1288dafeb3a83888c4ef75443..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
@@ -140,6 +151,21 @@ WVPASS bup split --bench -b <t/testfile1 >tags1.tmp
 WVPASS bup split -vvvv -b t/testfile2 >tags2.tmp
 WVPASS bup margin
 WVPASS bup midx -f
+WVPASS bup midx --check -a
+WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
+       $BUP_DIR/objects/pack/*.idx
+WVPASS bup midx --check -a
+WVPASS bup midx -o $BUP_DIR/objects/pack/test1.midx \
+       $BUP_DIR/objects/pack/*.idx \
+       $BUP_DIR/objects/pack/*.idx
+WVPASS bup midx --check -a
+all=$(echo $BUP_DIR/objects/pack/*.idx $BUP_DIR/objects/pack/*.midx)
+WVPASS bup midx -o $BUP_DIR/objects/pack/zzz.midx $all
+bup tick
+WVPASS bup midx -o $BUP_DIR/objects/pack/yyy.midx $all
+WVPASS bup midx -a
+WVPASSEQ "$(echo $BUP_DIR/objects/pack/*.midx)" \
+       "$BUP_DIR/objects/pack/yyy.midx"
 WVPASS bup margin
 WVPASS bup split -t t/testfile2 >tags2t.tmp
 WVPASS bup split -t t/testfile2 --fanout 3 >tags2tf.tmp
@@ -150,21 +176,34 @@ WVPASS ls -lR \
 WVPASS bup ls
 WVFAIL bup ls /does-not-exist
 WVPASS bup ls /lslr
+WVPASS bup ls /lslr/latest
+WVPASS bup ls /lslr/latest/
 #WVPASS bup ls /lslr/1971-01-01   # all dates always exist
 WVFAIL diff -u tags1.tmp tags2.tmp
 
 # fanout must be different from non-fanout
-WVFAIL diff -q tags2t.tmp tags2tf.tmp
+WVFAIL diff tags2t.tmp tags2tf.tmp
 wc -c t/testfile1 t/testfile2
 wc -l tags1.tmp tags2.tmp
 
+WVSTART "bloom"
+WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
+rm $BUP_DIR/objects/pack/bup.bloom
+WVPASS bup bloom -k 4
+WVPASS bup bloom -c $(ls -1 $BUP_DIR/objects/pack/*.idx|head -n1)
+WVPASS bup bloom -d buptest.tmp/objects/pack --ruin --force
+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 "join"
 WVPASS bup join $(cat tags1.tmp) >out1.tmp
 WVPASS bup join <tags2.tmp >out2.tmp
-WVPASS bup join <tags2t.tmp >out2t.tmp
+WVPASS bup join <tags2t.tmp -o out2t.tmp
 WVPASS bup join -r "$BUP_DIR" <tags2c.tmp >out2c.tmp
 WVPASS bup join -r ":$BUP_DIR" <tags2c.tmp >out2c.tmp
 WVPASS diff -u t/testfile1 out1.tmp
@@ -180,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 ]
@@ -189,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"
@@ -255,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"
@@ -349,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
@@ -396,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