#!/usr/bin/env bash
. wvtest.sh
+. t/lib.sh
+
#set -e
TOP="$(/bin/pwd)"
WVSTART "init"
#set -x
-rm -rf "$BUP_DIR"
+test -d "$BUP_DIR" && rm -r "$BUP_DIR"
WVPASS bup init
WVSTART "index"
D=bupdata.tmp
-rm -rf $D
+force-delete $D
mkdir $D
+WVFAIL bup index --exclude-from $D/cannot-exist $D
WVPASSEQ "$(bup index --check -p)" ""
WVPASSEQ "$(bup index --check -p $D)" ""
WVFAIL [ -e $D.fake ]
) || exit 1
WVSTART "restore"
-rm -rf buprestore.tmp
+force-delete 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
+force-delete 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/
+(
+ tmp=testrestore.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ 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 t/compare-trees $tmp/src/ $tmp/restore/latest/
+
+ WVSTART "restore /foo/latest/"
+ force-delete "$tmp/restore"
+ WVPASS bup restore -C $tmp/restore /foo/latest/
+ for x in $tmp/src/*; do
+ WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
+ done
+
+ WVSTART "restore /foo/latest/."
+ force-delete "$tmp/restore"
+ WVPASS bup restore -C $tmp/restore /foo/latest/.
+ WVPASS t/compare-trees $tmp/src/ $tmp/restore/
+
+ WVSTART "restore /foo/latest/x"
+ force-delete "$tmp/restore"
+ WVPASS bup restore -C $tmp/restore /foo/latest/x
+ WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/x/
+
+ WVSTART "restore /foo/latest/x/"
+ force-delete "$tmp/restore"
+ WVPASS bup restore -C $tmp/restore /foo/latest/x/
+ for x in $tmp/src/x/*; do
+ WVPASS t/compare-trees $x/ $tmp/restore/$(basename $x);
+ done
+
+ WVSTART "restore /foo/latest/x/."
+ force-delete "$tmp/restore"
+ WVPASS bup restore -C $tmp/restore /foo/latest/x/.
+ WVPASS t/compare-trees $tmp/src/x/ $tmp/restore/
+) || WVFAIL
+
+
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
WVSTART "exclude-bupdir"
D=exclude-bupdir.tmp
-rm -rf $D
+force-delete $D
mkdir $D
export BUP_DIR="$D/.bup"
WVPASS bup init
f"
WVSTART "exclude"
-D=exclude.tmp
-rm -rf $D
-mkdir $D
-export BUP_DIR="$D/.bup"
-WVPASS bup init
-touch $D/a
-WVPASS bup random 128k >$D/b
-mkdir $D/d $D/d/e
-WVPASS bup random 512 >$D/f
-WVPASS bup index -ux --exclude $D/d $D
-bup save -n exclude $D
-WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
+(
+ set -e -o pipefail
+ D=exclude.tmp
+ force-delete $D
+ mkdir $D
+ export BUP_DIR="$D/.bup"
+ WVPASS bup init
+ touch $D/a
+ WVPASS bup random 128k >$D/b
+ mkdir $D/d $D/d/e
+ WVPASS bup random 512 >$D/f
+ WVPASS bup random 512 >$D/j
+ WVPASS bup index -ux --exclude $D/d --exclude $D/j $D
+ bup save -n exclude $D
+ WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
b
f"
-mkdir $D/g $D/h
-WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h $D
-bup save -n exclude $D
-WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
+ mkdir $D/g $D/h
+ WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h \
+ --exclude $TOP/$D/j $D
+ bup save -n exclude $D
+ WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a
b
f"
+) || WVFAIL
WVSTART "exclude-from"
-D=exclude-fromdir.tmp
-EXCLUDE_FILE=exclude-from.tmp
-echo "$D/d
+(
+ set -e -o pipefail
+ D=exclude-fromdir.tmp
+ EXCLUDE_FILE=exclude-from.tmp
+ echo "$D/d
$TOP/$D/g
-$D/h" > $EXCLUDE_FILE
-rm -rf $D
-mkdir $D
-export BUP_DIR="$D/.bup"
-WVPASS bup init
-touch $D/a
-WVPASS bup random 128k >$D/b
-mkdir $D/d $D/d/e
-WVPASS bup random 512 >$D/f
-mkdir $D/g $D/h
-WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
-bup save -n exclude-from $D
-WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a
+$D/h
+$D/i" > $EXCLUDE_FILE
+ force-delete $D
+ mkdir $D
+ export BUP_DIR="$D/.bup"
+ WVPASS bup init
+ touch $D/a
+ WVPASS bup random 128k >$D/b
+ mkdir $D/d $D/d/e
+ WVPASS bup random 512 >$D/f
+ mkdir $D/g $D/h
+ WVPASS bup random 128k > $D/i
+ WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D
+ bup save -n exclude-from $D
+ WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a
b
f"
-rm $EXCLUDE_FILE
+ rm $EXCLUDE_FILE
+) || WVFAIL
-WVSTART "strip"
-D=strip.tmp
-rm -rf $D
-mkdir $D
-export BUP_DIR="$D/.bup"
-WVPASS bup init
-touch $D/a
-WVPASS bup random 128k >$D/b
-mkdir $D/d $D/d/e
-WVPASS bup random 512 >$D/f
-WVPASS bup index -ux $D
-bup save --strip -n strip $D
-WVPASSEQ "$(bup ls strip/latest/)" "a
-b
-d/
-f"
+WVSTART "save (no index)"
+(
+ set -e
+ tmp=save-no-index.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ WVFAIL bup save -n nothing /
+ rm -r "$tmp"
+) || WVFAIL
-WVSTART "strip-path"
-D=strip-path.tmp
-rm -rf $D
-mkdir $D
-export BUP_DIR="$D/.bup"
-WVPASS bup init
-touch $D/a
-WVPASS bup random 128k >$D/b
-mkdir $D/d $D/d/e
-WVPASS bup random 512 >$D/f
-WVPASS bup index -ux $D
-bup save --strip-path $TOP -n strip-path $D
-WVPASSEQ "$(bup ls strip-path/latest/$D/)" "a
-b
-d/
-f"
+WVSTART "save --strip"
+(
+ tmp=graft-points.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ 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/x/y
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/"
+) || WVFAIL
-WVSTART "graft_points"
-D=graft-points.tmp
-rm -rf $D
-mkdir $D
-export BUP_DIR="$D/.bup"
-WVPASS bup init
-touch $D/a
-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
-d/
-f"
-bup save --graft $D=grafted -n graft-point-relative $D
-WVPASSEQ "$(bup ls graft-point-relative/latest/$TOP/grafted/)" "a
-b
-d/
-f"
+WVSTART "save --strip-path (relative)"
+(
+ tmp=graft-points.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ 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-path $tmp/src -n foo $tmp/src/x
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/"
+) || WVFAIL
+
+WVSTART "save --strip-path (absolute)"
+(
+ tmp=graft-points.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ 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-path "$TOP" -n foo $tmp/src
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$tmp/src/"
+) || WVFAIL
+
+WVSTART "save --strip-path (no match)"
+(
+ tmp=graft-points.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ 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-path $tmp/foo -n foo $tmp/src/x
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/"
+) || WVFAIL
+
+WVSTART "save --graft (empty graft points disallowed)"
+(
+ tmp=graft-points.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ WVFAIL bup save --graft =/grafted -n graft-point-absolute $tmp
+ WVFAIL bup save --graft $TOP/$tmp= -n graft-point-absolute $tmp
+) || WVFAIL
+
+WVSTART "save --graft /x/y=/a/b (relative paths)"
+(
+ tmp=graft-points.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ 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 --graft $tmp/src=x -n foo $tmp/src
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/x/"
+) || WVFAIL
+
+WVSTART "save --graft /x/y=/a/b (matching structure)"
+(
+ tmp=graft-points.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ 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 -v --graft "$TOP/$tmp/src/x/y=$TOP/$tmp/src/a/b" \
+ -n foo $tmp/src/x/y
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/x/y/ \
+ "$tmp/restore/latest/$TOP/$tmp/src/a/b/"
+) || WVFAIL
+
+WVSTART "save --graft /x/y=/a (shorter target)"
+(
+ tmp=graft-points.tmp
+ force-delete $tmp
+ mkdir $tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ WVPASS bup init
+ 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 -v --graft "$TOP/$tmp/src/x/y=/a" -n foo $tmp/src/x/y
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/x/y/ "$tmp/restore/latest/a/"
+) || WVFAIL
+
+WVSTART "save --graft /x=/a/b (longer target)"
+(
+ tmp=graft-points.tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ force-delete $tmp
+ mkdir $tmp
+ WVPASS bup init
+ 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 -v --graft "$TOP/$tmp/src=$TOP/$tmp/src/a/b/c" \
+ -n foo $tmp/src
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/ "$tmp/restore/latest/$TOP/$tmp/src/a/b/c/"
+) || WVFAIL
+
+WVSTART "save --graft /x=/ (root target)"
+(
+ tmp=graft-points.tmp
+ export BUP_DIR="$(pwd)/$tmp/bup"
+ force-delete $tmp
+ mkdir $tmp
+ WVPASS bup init
+ 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 -v --graft "$TOP/$tmp/src/x=/" -n foo $tmp/src/x
+ WVPASS bup restore -C $tmp/restore /foo/latest
+ WVPASS t/compare-trees $tmp/src/x/ "$tmp/restore/latest/"
+) || WVFAIL
+
+#WVSTART "save --graft /=/x/ (root source)"
+# FIXME: Not tested for now -- will require cleverness, or caution as root.
WVSTART "indexfile"
D=indexfile.tmp
INDEXFILE=tmpindexfile.tmp
rm -f $INDEXFILE
-rm -rf $D
+force-delete $D
mkdir $D
export BUP_DIR="$D/.bup"
WVPASS bup init
WVSTART "import-rsnapshot"
D=rsnapshot.tmp
export BUP_DIR="$TOP/$D/.bup"
-rm -rf $D
+force-delete $D
mkdir $D
WVPASS bup init
mkdir -p $D/hourly.0/buptest/a
WVSTART "import-rdiff-backup"
D=rdiff-backup.tmp
export BUP_DIR="$TOP/$D/.bup"
- rm -rf $D
+ force-delete $D
mkdir $D
WVPASS bup init
mkdir $D/rdiff-backup
WVSTART "compression"
D=compression0.tmp
export BUP_DIR="$TOP/$D/.bup"
-rm -rf $D
+force-delete $D
mkdir $D
WVPASS bup init
WVPASS bup index $TOP/Documentation
# is harmless there.)
WVPASSEQ "$(bup ls compression/latest/ | sort)" \
"$(ls $TOP/Documentation | grep -v '^\.' | sort)"
-COMPRESSION_0_SIZE=$(du -B 1024 -s $D | cut -f1)
+COMPRESSION_0_SIZE=$(du -k -s $D | cut -f1)
D=compression9.tmp
export BUP_DIR="$TOP/$D/.bup"
-rm -rf $D
+force-delete $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 -B 1024 -s $D | cut -f1)
+WVPASSEQ "$(bup ls compression/latest/ | sort)" \
+ "$(ls $TOP/Documentation | grep -v '^\.' | sort)"
+COMPRESSION_9_SIZE=$(du -k -s $D | cut -f1)
WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ]
exit 0
fi
D=bupdata.tmp
- rm -rf $D
+ force-delete $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; }
+ tmpdir="$(mktemp -d /tmp/bup-test-XXXXXXX)"
+ cleanup() { set -x; rm -r "${tmpdir}"; set +x; }
trap cleanup EXIT
date > "$tmpdir/2"
export BUP_DIR="$TOP/buptest.tmp"
- rm -rf "$BUP_DIR"
+ test -d "$BUP_DIR" && rm -r "$BUP_DIR"
WVPASS bup init
WVPASS bup index -vu $(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
+
+WVSTART "clear-index"
+D=clear-index.tmp
+export BUP_DIR="$TOP/$D/.bup"
+force-delete $TOP/$D
+mkdir $TOP/$D
+WVPASS bup init
+touch $TOP/$D/foo
+touch $TOP/$D/bar
+bup index -u $D
+WVPASSEQ "$(bup index -p)" "$D/foo
+$D/bar
+$D/
+./"
+rm $TOP/$D/foo
+WVPASS bup index --clear
+bup index -u $TOP/$D
+WVPASSEQ "$(bup index -p)" "$D/bar
+$D/
+./"
+
+# bup index --exclude-rx ...
+(
+ set -e
+ export BUP_DIR="$TOP/buptest.tmp"
+ D=bupdata.tmp
+
+ WVSTART "index --exclude-rx '^/foo' (root anchor)"
+ rm -rf "$D" "$BUP_DIR" buprestore.tmp
+ WVPASS bup init
+ mkdir $D
+ touch $D/a
+ touch $D/b
+ mkdir $D/sub1
+ mkdir $D/sub2
+ touch $D/sub1/a
+ touch $D/sub2/b
+ WVPASS bup index -u $D --exclude-rx "^$(pwd)/$D/sub1/"
+ bup save --strip -n bupdir $D
+ bup restore -C buprestore.tmp /bupdir/latest/
+ WVPASSEQ "$(cd buprestore.tmp && find . | sort)" ".
+./a
+./b
+./sub2
+./sub2/b"
+
+ WVSTART "index --exclude-rx '/foo$' (non-dir, tail anchor)"
+ rm -rf "$D" "$BUP_DIR" buprestore.tmp
+ WVPASS bup init
+ mkdir $D
+ touch $D/a
+ touch $D/b
+ touch $D/foo
+ mkdir $D/sub
+ mkdir $D/sub/foo
+ touch $D/sub/foo/a
+ WVPASS bup index -u $D --exclude-rx '/foo$'
+ bup save --strip -n bupdir $D
+ bup restore -C buprestore.tmp /bupdir/latest/
+ WVPASSEQ "$(cd buprestore.tmp && find . | sort)" ".
+./a
+./b
+./sub
+./sub/foo
+./sub/foo/a"
+
+ WVSTART "index --exclude-rx '/foo/$' (dir, tail anchor)"
+ rm -rf "$D" "$BUP_DIR" buprestore.tmp
+ WVPASS bup init
+ mkdir $D
+ touch $D/a
+ touch $D/b
+ touch $D/foo
+ mkdir $D/sub
+ mkdir $D/sub/foo
+ touch $D/sub/foo/a
+ WVPASS bup index -u $D --exclude-rx '/foo/$'
+ bup save --strip -n bupdir $D
+ bup restore -C buprestore.tmp /bupdir/latest/
+ WVPASSEQ "$(cd buprestore.tmp && find . | sort)" ".
+./a
+./b
+./foo
+./sub"
+
+ WVSTART "index --exclude-rx '/foo/.' (dir content)"
+ rm -rf "$D" "$BUP_DIR" buprestore.tmp
+ WVPASS bup init
+ mkdir $D
+ touch $D/a
+ touch $D/b
+ touch $D/foo
+ mkdir $D/sub
+ mkdir $D/sub/foo
+ touch $D/sub/foo/a
+ WVPASS bup index -u $D --exclude-rx '/foo/.'
+ bup save --strip -n bupdir $D
+ bup restore -C buprestore.tmp /bupdir/latest/
+ WVPASSEQ "$(cd buprestore.tmp && find . | sort)" ".
+./a
+./b
+./foo
+./sub
+./sub/foo"
+) || WVFAIL
+
+
+# bup restore --exclude-rx ...
+(
+ set -e
+ export BUP_DIR="$TOP/buptest.tmp"
+ D=bupdata.tmp
+
+ WVSTART "restore --exclude-rx '^/foo' (root anchor)"
+ rm -rf "$D" "$BUP_DIR" buprestore.tmp
+ WVPASS bup init
+ mkdir $D
+ touch $D/a
+ touch $D/b
+ mkdir $D/sub1
+ mkdir $D/sub2
+ touch $D/sub1/a
+ touch $D/sub2/b
+ WVPASS bup index -u $D
+ bup save --strip -n bupdir $D
+ bup restore -C buprestore.tmp --exclude-rx "^/sub1/" /bupdir/latest/
+ WVPASSEQ "$(cd buprestore.tmp && find . | sort)" ".
+./a
+./b
+./sub2
+./sub2/b"
+
+ WVSTART "restore --exclude-rx '/foo$' (non-dir, tail anchor)"
+ rm -rf "$D" "$BUP_DIR" buprestore.tmp
+ WVPASS bup init
+ mkdir $D
+ touch $D/a
+ touch $D/b
+ touch $D/foo
+ mkdir $D/sub
+ mkdir $D/sub/foo
+ touch $D/sub/foo/a
+ WVPASS bup index -u $D
+ bup save --strip -n bupdir $D
+ bup restore -C buprestore.tmp --exclude-rx '/foo$' /bupdir/latest/
+ WVPASSEQ "$(cd buprestore.tmp && find . | sort)" ".
+./a
+./b
+./sub
+./sub/foo
+./sub/foo/a"
+
+ WVSTART "restore --exclude-rx '/foo/$' (dir, tail anchor)"
+ rm -rf "$D" "$BUP_DIR" buprestore.tmp
+ WVPASS bup init
+ mkdir $D
+ touch $D/a
+ touch $D/b
+ touch $D/foo
+ mkdir $D/sub
+ mkdir $D/sub/foo
+ touch $D/sub/foo/a
+ WVPASS bup index -u $D
+ bup save --strip -n bupdir $D
+ bup restore -C buprestore.tmp --exclude-rx '/foo/$' /bupdir/latest/
+ WVPASSEQ "$(cd buprestore.tmp && find . | sort)" ".
+./a
+./b
+./foo
+./sub"
+
+ WVSTART "restore --exclude-rx '/foo/.' (dir content)"
+ rm -rf "$D" "$BUP_DIR" buprestore.tmp
+ WVPASS bup init
+ mkdir $D
+ touch $D/a
+ touch $D/b
+ touch $D/foo
+ mkdir $D/sub
+ mkdir $D/sub/foo
+ touch $D/sub/foo/a
+ WVPASS bup index -u $D
+ bup save --strip -n bupdir $D
+ bup restore -C buprestore.tmp --exclude-rx '/foo/.' /bupdir/latest/
+ WVPASSEQ "$(cd buprestore.tmp && find . | sort)" ".
+./a
+./b
+./foo
+./sub
+./sub/foo"
+) || WVFAIL