8 top="$(WVPASS pwd)" || exit $?
9 tmpdir="$(WVPASS wvmktempdir)" || exit $?
10 export BUP_DIR="$tmpdir/bup"
12 bup() { "$top/bup" "$@"; }
14 validate-local-and-remote-restore()
16 local src="$1" dest="$2" cmp_src="$3" cmp_dest="$4"
18 WVPASS bup restore -C "$dest" "$src"
19 WVPASS "$top/t/compare-trees" "$cmp_src" "$cmp_dest"
21 WVPASS bup restore -r ":$BUP_DIR" -C "$dest" "$src"
22 WVPASS "$top/t/compare-trees" "$cmp_src" "$cmp_dest"
31 WVPASS force-delete $D
34 WVPASS bup random 128k >$D/b
35 WVPASS mkdir $D/d $D/d/e
36 WVPASS bup random 512 >$D/f
44 WVPASS force-delete buprestore.tmp
45 WVFAIL bup restore boink
46 WVPASS touch "$tmpdir/$D/$D"
47 WVPASS bup index -u "$tmpdir/$D"
48 WVPASS bup save -n master /
49 WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D"
50 WVPASSEQ "$(ls buprestore.tmp)" "bupdata.tmp"
51 WVPASS force-delete buprestore.tmp
52 WVPASS bup restore -C buprestore.tmp "/master/latest/$tmpdir/$D/"
53 WVPASS touch $D/non-existent-file buprestore.tmp/non-existent-file # else diff fails
54 WVPASS diff -ur $D/ buprestore.tmp/
55 WVPASS force-delete buprestore.tmp
56 WVPASS echo -n "" | WVPASS bup split -n split_empty_string.tmp
57 WVPASS bup restore -C buprestore.tmp split_empty_string.tmp/latest/
58 WVPASSEQ "$(cat buprestore.tmp/data)" ""
63 WVPASS force-delete $tmp
65 export BUP_DIR="$(pwd)/$tmp/bup"
66 WVPASS WVPASS bup init
67 WVPASS mkdir -p $tmp/src/x/y/z
68 WVPASS bup random 8k > $tmp/src/x/y/random-1
69 WVPASS bup random 8k > $tmp/src/x/y/z/random-2
70 WVPASS bup index -u $tmp/src
71 WVPASS bup save --strip -n foo $tmp/src
73 WVSTART "restore /foo/latest"
74 validate-local-and-remote-restore \
75 /foo/latest "$tmp/restore" \
76 "$tmp/src/" "$tmp/restore/latest/"
78 WVSTART "restore /foo/latest/."
79 WVPASS force-delete "$tmp/restore"
80 validate-local-and-remote-restore \
81 /foo/latest/. "$tmp"/restore \
82 "$tmp"/src/ "$tmp"/restore
84 WVSTART "restore /foo/latest/x"
85 WVPASS force-delete "$tmp/restore"
86 validate-local-and-remote-restore \
87 /foo/latest/x "$tmp"/restore \
88 "$tmp"/src/x/ "$tmp"/restore/x/
90 WVSTART "restore /foo/latest/x/"
91 WVPASS force-delete "$tmp/restore"
92 WVPASS bup restore -C "$tmp"/restore /foo/latest/x/
93 for x in "$tmp"/src/x/*; do
94 WVPASS "$top/t/compare-trees" "$x/" "$tmp/restore/$(basename $x)"
96 WVPASS force-delete "$tmp/restore"
97 WVPASS bup restore -r ":$BUP_DIR" -C "$tmp"/restore /foo/latest/x/
98 for x in "$tmp"/src/x/*; do
99 WVPASS "$top/t/compare-trees" "$x/" "$tmp/restore/$(basename $x)"
102 WVSTART "restore /foo/latest/x/."
103 WVPASS force-delete "$tmp/restore"
104 validate-local-and-remote-restore \
105 /foo/latest/x/. "$tmp"/restore \
106 "$tmp"/src/x/ "$tmp"/restore/
110 WVSTART "save (no index)"
112 tmp=save-no-index.tmp
113 WVPASS force-delete $tmp
115 export BUP_DIR="$(WVPASS pwd)/$tmp/bup" || exit $?
117 WVFAIL bup save -n nothing /
122 WVSTART "save disjoint top-level directories"
124 # Resolve any symlinks involving the top top-level dirs.
125 real_pwd="$(WVPASS resolve-parent .)" || exit $?
126 real_tmp="$(WVPASS resolve-parent /tmp/.)" || exit $?
127 pwd_top="$(echo $real_pwd | WVPASS awk -F "/" '{print $2}')" || exit $?
128 tmp_top="$(echo $real_tmp | WVPASS awk -F "/" '{print $2}')" || exit $?
130 if [ "$pwd_top" = "$tmp_top" ]; then
131 echo "(running from within /$tmp_top; skipping test)" 1>&2
135 WVPASS force-delete $D
138 tmpdir2="$(WVPASS mktemp -d $real_tmp/bup-test-XXXXXXX)" || exit $?
139 cleanup() { WVPASS rm -r "$tmpdir2"; }
140 WVPASS trap cleanup EXIT
141 WVPASS date > "$tmpdir2/2"
143 export BUP_DIR="$tmpdir/bup"
144 WVPASS test -d "$BUP_DIR" && WVPASS rm -r "$BUP_DIR"
147 WVPASS bup index -vu $(pwd)/$D/x "$tmpdir2"
148 WVPASS bup save -t -n src $(pwd)/$D/x "$tmpdir2"
150 # For now, assume that "ls -a" and "sort" use the same order.
151 actual="$(WVPASS bup ls -AF src/latest)" || exit $?
152 expected="$(echo -e "$pwd_top/\n$tmp_top/" | WVPASS sort)" || exit $?
153 WVPASSEQ "$actual" "$expected"
158 WVPASS rm -rf "$tmpdir"