8 top="$(WVPASS pwd)" || exit $?
9 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
12 bup() { "$top/bup" "$@"; }
21 WVPASS force-delete $D
24 WVPASS bup random 128k >$D/b
25 WVPASS mkdir $D/d $D/d/e
26 WVPASS bup random 512 >$D/f
33 WVPASS force-delete buprestore.tmp
34 WVFAIL bup restore boink
35 WVPASS touch "$tmpdir/$D/$D"
36 WVPASS bup index -u "$tmpdir/$D"
37 WVPASS bup save -n master /
38 WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D"
39 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
40 WVPASS force-delete buprestore.tmp
41 WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D/"
42 WVPASS touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
43 WVPASS diff -ur $D/ buprestore.tmp/
44 WVPASS force-delete buprestore.tmp
45 WVPASS echo -n "" | WVPASS bup split -n split_empty_string.tmp
46 WVPASS bup restore -C buprestore.tmp split_empty_string.tmp/latest/
47 WVPASSEQ "$(cat buprestore.tmp/data)" ""
51 WVPASS force-delete $tmp
53 export BUP_DIR="$(pwd)/$tmp/bup"
54 WVPASS WVPASS bup init
55 WVPASS mkdir -p $tmp/src/x/y/z
56 WVPASS bup random 8k > $tmp/src/x/y/random-1
57 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
58 WVPASS bup index -u $tmp/src
59 WVPASS bup save --strip -n foo $tmp/src
61 WVSTART "restore /foo/latest"
62 WVPASS bup restore -C $tmp/restore /foo/latest
63 WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/latest/
65 WVSTART "restore /foo/latest/"
66 WVPASS force-delete "$tmp/restore"
67 WVPASS bup restore -C $tmp/restore /foo/latest/
68 for x in $tmp/src/*; do
69 WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
72 WVSTART "restore /foo/latest/."
73 WVPASS force-delete "$tmp/restore"
74 WVPASS bup restore -C $tmp/restore /foo/latest/.
75 WVPASS "$top/t/compare-trees" $tmp/src/ $tmp/restore/
77 WVSTART "restore /foo/latest/x"
78 WVPASS force-delete "$tmp/restore"
79 WVPASS bup restore -C $tmp/restore /foo/latest/x
80 WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/x/
82 WVSTART "restore /foo/latest/x/"
83 WVPASS force-delete "$tmp/restore"
84 WVPASS bup restore -C $tmp/restore /foo/latest/x/
85 for x in $tmp/src/x/*; do
86 WVPASS "$top/t/compare-trees" $x/ $tmp/restore/$(basename $x);
89 WVSTART "restore /foo/latest/x/."
90 WVPASS force-delete "$tmp/restore"
91 WVPASS bup restore -C $tmp/restore /foo/latest/x/.
92 WVPASS "$top/t/compare-trees" $tmp/src/x/ $tmp/restore/
96 WVSTART "save (no index)"
99 WVPASS force-delete $tmp
101 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
103 WVFAIL bup save -n nothing /
107 WVSTART "save disjoint top-level directories"
109 # Resolve any symlinks involving the top top-level dirs.
110 real_pwd="$(WVPASS resolve-parent .)" || exit $?
111 real_tmp="$(WVPASS resolve-parent /tmp/.)" || exit $?
112 pwd_top="$(echo $real_pwd | WVPASS awk -F "/" '{print $2}')" || exit $?
113 tmp_top="$(echo $real_tmp | WVPASS awk -F "/" '{print $2}')" || exit $?
115 if [ "$pwd_top" = "$tmp_top" ]; then
116 echo "(running from within /$tmp_top; skipping test)" 1>&2
120 WVPASS force-delete $D
123 tmpdir2="$(WVPASS mktemp -d $real_tmp/bup-test-XXXXXXX)" || exit $?
124 cleanup() { WVPASS rm -r "$tmpdir2"; }
125 WVPASS trap cleanup EXIT
126 WVPASS date > "$tmpdir2/2"
128 export BUP_DIR="$tmpdir/bup"
129 WVPASS test -d "$BUP_DIR" && WVPASS rm -r "$BUP_DIR"
132 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir2"
133 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir2"
135 # For now, assume that "ls -a" and "sort" use the same order.
136 actual="$(WVPASS bup ls -AF src/latest)" || exit $?
137 expected="$(echo -e "$pwd_top/\n$tmp_top/" | WVPASS sort)" || exit $?
138 WVPASSEQ "$actual" "$expected"
141 WVPASS rm -rf "$tmpdir"