-#!/bin/bash
+#!/usr/bin/env bash
. wvtest.sh
#set -e
WVFAIL bup index --check -u $D.fake
WVPASS bup index --check -u $D
WVPASSEQ "$(bup index --check -p $D)" "$D/"
-touch $D/a $D/b $D/f
+touch $D/a
+bup random 128k >$D/b
mkdir $D/d $D/d/e
+bup random 512 >$D/f
WVPASSEQ "$(bup index -s $D/)" "A $D/"
WVPASSEQ "$(bup index -s $D/b)" ""
WVPASSEQ "$(bup index --check -us $D/b)" "A $D/b"
./"
WVPASSEQ "$(cd $D && bup index -s .)" "$(cd $D && bup index -s .)"
+WVFAIL bup save -t $D/doesnt-exist-filename
+
+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
+rm -f $D/d/e/fifotest
+WVPASS bup index -u $D/d/e
+WVFAIL bup save -t $D/d/e/fifotest
+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
WVPASS [ "$n" -eq 0 ]
) || exit 1
+WVSTART "ftp"
+WVPASS bup ftp "cat /master/latest/$TOP/$D/b" >$D/b.new
+WVPASS bup ftp "cat /master/latest/$TOP/$D/f" >$D/f.new
+WVPASS bup ftp "cat /master/latest/$TOP/$D/f"{,} >$D/f2.new
+WVPASS bup ftp "cat /master/latest/$TOP/$D/a" >$D/a.new
+WVPASSEQ "$(sha1sum <$D/b)" "$(sha1sum <$D/b.new)"
+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 "fsck"
WVPASS bup fsck
WVPASS bup fsck --quick